Class CodeAction

java.lang.Object
org.graalvm.tools.lsp.server.types.JSONBase
org.graalvm.tools.lsp.server.types.CodeAction

public class CodeAction extends JSONBase
A 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 `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed.
  • Method Details

    • getTitle

      public String getTitle()
      A short, human-readable, title for this code action.
    • setTitle

      public CodeAction setTitle(String title)
    • getKind

      public CodeActionKind getKind()
      The kind of the code action. Used to filter code actions.
    • setKind

      public CodeAction setKind(CodeActionKind kind)
    • getDiagnostics

      public List<Diagnostic> getDiagnostics()
      The diagnostics that this code action resolves.
    • setDiagnostics

      public CodeAction setDiagnostics(List<Diagnostic> diagnostics)
    • getIsPreferred

      public 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 CodeAction setIsPreferred(Boolean isPreferred)
    • getEdit

      public WorkspaceEdit getEdit()
      The workspace edit this code action performs.
    • setEdit

      public CodeAction setEdit(WorkspaceEdit edit)
    • 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 CodeAction setCommand(Command command)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • create

      public static CodeAction create(String title, Command command, CodeActionKind kind)
      Creates a new code action.
      Parameters:
      title - The title of the code action.
      command - The command to execute.
      kind - The kind of the code action.
    • create

      public static CodeAction create(String title, WorkspaceEdit edit, CodeActionKind kind)
      Creates a new code action.
      Parameters:
      title - The title of the code action.
      edit - The workspace edit to perform.
      kind - The kind of the code action.
    • create

      public static CodeAction create(String title, Object commandOrEdit, CodeActionKind kind)