Class CodeAction
- java.lang.Object
-
- org.eclipse.lsp4j.CodeAction
-
public class CodeAction extends java.lang.ObjectA code action represents a change that can be performed in code, e.g. to fix a problem or to refactor code.A CodeAction must set either
editand/or acommand. If both are supplied, theeditis applied first, then thecommandis executed.
-
-
Constructor Summary
Constructors Constructor Description CodeAction()CodeAction(java.lang.String title)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)CommandgetCommand()A command this code action executes.java.lang.ObjectgetData()A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.java.util.List<Diagnostic>getDiagnostics()The diagnostics that this code action resolves.CodeActionDisabledgetDisabled()Marks that the code action cannot currently be applied.WorkspaceEditgetEdit()The workspace edit this code action performs.java.lang.BooleangetIsPreferred()Marks this as a preferred action.java.lang.StringgetKind()The kind of the code action.java.lang.StringgetTitle()A short, human-readable, title for this code action.inthashCode()voidsetCommand(Command command)A command this code action executes.voidsetData(java.lang.Object data)A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.voidsetDiagnostics(java.util.List<Diagnostic> diagnostics)The diagnostics that this code action resolves.voidsetDisabled(CodeActionDisabled disabled)Marks that the code action cannot currently be applied.voidsetEdit(WorkspaceEdit edit)The workspace edit this code action performs.voidsetIsPreferred(java.lang.Boolean isPreferred)Marks this as a preferred action.voidsetKind(java.lang.String kind)The kind of the code action.voidsetTitle(java.lang.String title)A short, human-readable, title for this code action.java.lang.StringtoString()
-
-
-
Method Detail
-
getTitle
public java.lang.String getTitle()
A short, human-readable, title for this code action.
-
setTitle
public void setTitle(java.lang.String title)
A short, human-readable, title for this code action.
-
getKind
public java.lang.String getKind()
The kind of the code action.Used to filter code actions.
See
CodeActionKindfor some predefined code action kinds.
-
setKind
public void setKind(java.lang.String kind)
The kind of the code action.Used to filter code actions.
See
CodeActionKindfor some predefined code action kinds.
-
getDiagnostics
public java.util.List<Diagnostic> getDiagnostics()
The diagnostics that this code action resolves.
-
setDiagnostics
public void setDiagnostics(java.util.List<Diagnostic> diagnostics)
The diagnostics that this code action resolves.
-
getIsPreferred
public java.lang.Boolean getIsPreferred()
Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted by keybindings.A quick fix should be marked preferred if it properly addresses the underlying error. A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
Since 3.15.0
-
setIsPreferred
public void setIsPreferred(java.lang.Boolean isPreferred)
Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted by keybindings.A quick fix should be marked preferred if it properly addresses the underlying error. A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
Since 3.15.0
-
getDisabled
public CodeActionDisabled getDisabled()
Marks that the code action cannot currently be applied.Clients should follow the following guidelines regarding disabled code actions:
- Disabled code actions are not shown in automatic lightbulb code action menu.
- Disabled actions are shown as faded out in the code action menu when the user request a more specific type of code action, such as refactorings.
- If the user has a keybinding
that auto applies a code action and only a disabled code actions are returned, the client should show the user an
error message with
CodeActionDisabled.reasonin the editor.
Since 3.16.0
-
setDisabled
public void setDisabled(CodeActionDisabled disabled)
Marks that the code action cannot currently be applied.Clients should follow the following guidelines regarding disabled code actions:
- Disabled code actions are not shown in automatic lightbulb code action menu.
- Disabled actions are shown as faded out in the code action menu when the user request a more specific type of code action, such as refactorings.
- If the user has a keybinding
that auto applies a code action and only a disabled code actions are returned, the client should show the user an
error message with
CodeActionDisabled.reasonin the editor.
Since 3.16.0
-
getEdit
public WorkspaceEdit getEdit()
The workspace edit this code action performs.
-
setEdit
public void setEdit(WorkspaceEdit edit)
The workspace edit this code action performs.
-
getCommand
public Command getCommand()
A command this code action executes. If a code action provides a edit and a command, first the edit is executed and then the command.
-
setCommand
public void setCommand(Command command)
A command this code action executes. If a code action provides a edit and a command, first the edit is executed and then the command.
-
getData
public java.lang.Object getData()
A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.Since 3.16.0
-
setData
public void setData(java.lang.Object data)
A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.Since 3.16.0
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-