Top Description Fields Constructors Methods
org.eclipse.lsp4j

public Class CodeAction

extends Object
Class Inheritance
Annotations
@SuppressWarnings:all
Imports
com.google.gson.annotations.JsonAdapter, java.util.List, org.eclipse.lsp4j.jsonrpc.json.adapters.JsonElementTypeAdapter, org.eclipse.lsp4j.jsonrpc.util.Preconditions, .ToStringBuilder, org.eclipse.lsp4j.jsonrpc.validation.NonNull

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.

Field Summary

Modifier and TypeField and Description
private Command
command

A command this code action executes.

private Object
data

A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.

private List<Diagnostic>
diagnostics

The diagnostics that this code action resolves.

private CodeActionDisabled
disabled

Marks that the code action cannot currently be applied.

private WorkspaceEdit
edit

The workspace edit this code action performs.

private Boolean
isPreferred

Marks this as a preferred action.

private String
kind

The kind of the code action.

private String
title

A short, human-readable, title for this code action.

Constructor Summary

AccessConstructor and Description
public
public
CodeAction(final String title)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Command
getCommand()

A command this code action executes.

public Object
getData()

A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.

public List<Diagnostic>
getDiagnostics()

The diagnostics that this code action resolves.

public CodeActionDisabled
getDisabled()

Marks that the code action cannot currently be applied.

public WorkspaceEdit
getEdit()

The workspace edit this code action performs.

public Boolean
getIsPreferred()

Marks this as a preferred action.

public String
getKind()

The kind of the code action.

public String
getTitle()

A short, human-readable, title for this code action.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
setCommand(final Command command)

A command this code action executes.

public void
setData(final Object data)

A data entry field that is preserved on a code action between a `textDocument/codeAction` and a `codeAction/resolve` request.

public void
setDiagnostics(final List<Diagnostic> diagnostics)

The diagnostics that this code action resolves.

public void
setDisabled(final CodeActionDisabled disabled)

Marks that the code action cannot currently be applied.

public void
setEdit(final WorkspaceEdit edit)

The workspace edit this code action performs.

public void
setIsPreferred(final Boolean isPreferred)

Marks this as a preferred action.

public void
setKind(final String kind)

The kind of the code action.

public void
setTitle(final String title)

A short, human-readable, title for this code action.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

commandback to summary
private 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.

databack to summary
private 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

Annotations
@JsonAdapter:Factory
diagnosticsback to summary
private List<Diagnostic> diagnostics

The diagnostics that this code action resolves.

disabledback to summary
private 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#reason in the editor.

Since 3.16.0

editback to summary
private WorkspaceEdit edit

The workspace edit this code action performs.

isPreferredback to summary
private 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

kindback to summary
private String kind

The kind of the code action.

Used to filter code actions.

See CodeActionKind for some predefined code action kinds.

titleback to summary
private String title

A short, human-readable, title for this code action.

Annotations
@NonNull

Constructor Detail

CodeActionback to summary
public CodeAction()
CodeActionback to summary
public CodeAction(final String title)

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getCommandback to summary
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.

getDataback to summary
public 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

getDiagnosticsback to summary
public List<Diagnostic> getDiagnostics()

The diagnostics that this code action resolves.

getDisabledback to summary
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#reason in the editor.

Since 3.16.0

getEditback to summary
public WorkspaceEdit getEdit()

The workspace edit this code action performs.

getIsPreferredback to summary
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

getKindback to summary
public String getKind()

The kind of the code action.

Used to filter code actions.

See CodeActionKind for some predefined code action kinds.

getTitleback to summary
public String getTitle()

A short, human-readable, title for this code action.

Annotations
@NonNull
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
setCommandback to summary
public void setCommand(final 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.

setDataback to summary
public void setData(final 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

setDiagnosticsback to summary
public void setDiagnostics(final List<Diagnostic> diagnostics)

The diagnostics that this code action resolves.

setDisabledback to summary
public void setDisabled(final 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#reason in the editor.

Since 3.16.0

setEditback to summary
public void setEdit(final WorkspaceEdit edit)

The workspace edit this code action performs.

setIsPreferredback to summary
public void setIsPreferred(final 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

setKindback to summary
public void setKind(final String kind)

The kind of the code action.

Used to filter code actions.

See CodeActionKind for some predefined code action kinds.

setTitleback to summary
public void setTitle(final String title)

A short, human-readable, title for this code action.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override