Top Description Fields Constructors Methods
org.eclipse.lsp4j

public Class CompletionItem

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

The Completion request is sent from the client to the server to compute completion items at a given cursor position. Completion items are presented in the IntelliSense user class. If computing complete completion items is expensive servers can additional provide a handler for the resolve completion item request. This request is send when a completion item is selected in the user class.

Field Summary

Modifier and TypeField and Description
private List<TextEdit>
additionalTextEdits

An optional array of additional text edits that are applied when selecting this completion.

private Command
command

An optional command that is executed after inserting this completion

Note

that additional modifications to the current document should be described with the additionalTextEdits property.

private List<String>
commitCharacters

An optional set of characters that when pressed while this completion is active will accept it first and then type that character

Note

that all commit characters should have length=1 and that superfluous characters will be ignored.

private Object
data

A data entry field that is preserved on a completion item between a completion and a completion resolve request.

private Boolean
deprecated

Deprecated Use tags instead if supported.
Indicates if this item is deprecated.
private String
detail

A human-readable string with additional information about this item, like type or symbol information.

private Either<String, MarkupContent>
documentation

A human-readable string that represents a doc-comment.

private String
filterText

A string that should be used when filtering a set of completion items.

private String
insertText

A string that should be inserted a document when selecting this completion.

private InsertTextFormat
insertTextFormat

The format of the insert text.

private InsertTextMode
insertTextMode

How whitespace and indentation is handled during completion item insertion.

private CompletionItemKind
kind

The kind of this completion item.

private String
label

The label of this completion item.

private CompletionItemLabelDetails
labelDetails

Additional details for the label

Since 3.17.0

private Boolean
preselect

Select this item when showing.

private String
sortText

A string that should be used when comparing this item with other items.

private List<CompletionItemTag>
tags

Tags for this completion item.

private Either<TextEdit, InsertReplaceEdit>
textEdit

An edit which is applied to a document when selecting this completion.

private String
textEditText

The edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range.

Constructor Summary

AccessConstructor and Description
public
public
CompletionItem(final String label)

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 List<TextEdit>
getAdditionalTextEdits()

An optional array of additional text edits that are applied when selecting this completion.

public Command
getCommand()

An optional command that is executed after inserting this completion

Note

that additional modifications to the current document should be described with the additionalTextEdits property.

public List<String>
getCommitCharacters()

An optional set of characters that when pressed while this completion is active will accept it first and then type that character

Note

that all commit characters should have length=1 and that superfluous characters will be ignored.

public Object
getData()

A data entry field that is preserved on a completion item between a completion and a completion resolve request.

public Boolean
getDeprecated()
Deprecated Use tags instead if supported.

Indicates if this item is deprecated.

public String
getDetail()

A human-readable string with additional information about this item, like type or symbol information.

public Either<String, MarkupContent>
getDocumentation()

A human-readable string that represents a doc-comment.

public String
getFilterText()

A string that should be used when filtering a set of completion items.

public String
getInsertText()

A string that should be inserted a document when selecting this completion.

public InsertTextFormat
getInsertTextFormat()

The format of the insert text.

public InsertTextMode
getInsertTextMode()

How whitespace and indentation is handled during completion item insertion.

public CompletionItemKind
getKind()

The kind of this completion item.

public String
getLabel()

The label of this completion item.

public CompletionItemLabelDetails
getLabelDetails()

Additional details for the label

Since 3.17.0

public Boolean
getPreselect()

Select this item when showing.

public String
getSortText()

A string that should be used when comparing this item with other items.

public List<CompletionItemTag>
getTags()

Tags for this completion item.

public Either<TextEdit, InsertReplaceEdit>
getTextEdit()

An edit which is applied to a document when selecting this completion.

public String
getTextEditText()

The edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
setAdditionalTextEdits(final List<TextEdit> additionalTextEdits)

An optional array of additional text edits that are applied when selecting this completion.

public void
setCommand(final Command command)

An optional command that is executed after inserting this completion

Note

that additional modifications to the current document should be described with the additionalTextEdits property.

public void
setCommitCharacters(final List<String> commitCharacters)

An optional set of characters that when pressed while this completion is active will accept it first and then type that character

Note

that all commit characters should have length=1 and that superfluous characters will be ignored.

public void
setData(final Object data)

A data entry field that is preserved on a completion item between a completion and a completion resolve request.

public void
setDeprecated(final Boolean deprecated)
Deprecated Use tags instead if supported.

Indicates if this item is deprecated.

public void
setDetail(final String detail)

A human-readable string with additional information about this item, like type or symbol information.

public void
setDocumentation(final Either<String, MarkupContent> documentation)

A human-readable string that represents a doc-comment.

public void
setDocumentation(final String documentation)

public void
setDocumentation(final MarkupContent documentation)

public void
setFilterText(final String filterText)

A string that should be used when filtering a set of completion items.

public void
setInsertText(final String insertText)

A string that should be inserted a document when selecting this completion.

public void
setInsertTextFormat(final InsertTextFormat insertTextFormat)

The format of the insert text.

public void
setInsertTextMode(final InsertTextMode insertTextMode)

How whitespace and indentation is handled during completion item insertion.

public void
setKind(final CompletionItemKind kind)

The kind of this completion item.

public void
setLabel(final String label)

The label of this completion item.

public void
setLabelDetails(final CompletionItemLabelDetails labelDetails)

Additional details for the label

Since 3.17.0

public void
setPreselect(final Boolean preselect)

Select this item when showing.

public void
setSortText(final String sortText)

A string that should be used when comparing this item with other items.

public void
setTags(final List<CompletionItemTag> tags)

Tags for this completion item.

public void
setTextEdit(final Either<TextEdit, InsertReplaceEdit> textEdit)

An edit which is applied to a document when selecting this completion.

public void
setTextEditText(final String textEditText)

The edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

additionalTextEditsback to summary
private List<TextEdit> additionalTextEdits

An optional array of additional text edits that are applied when selecting this completion. Edits must not overlap (including the same insert position) with the main edit nor with themselves.

Additional text edits should be used to change text unrelated to the current cursor position (for example adding an import statement at the top of the file if the completion item will insert an unqualified type).

commandback to summary
private Command command

An optional command that is executed after inserting this completion

Note

that additional modifications to the current document should be described with the additionalTextEdits property.

commitCharactersback to summary
private List<String> commitCharacters

An optional set of characters that when pressed while this completion is active will accept it first and then type that character

Note

that all commit characters should have length=1 and that superfluous characters will be ignored.

Since 3.2.0

databack to summary
private Object data

A data entry field that is preserved on a completion item between a completion and a completion resolve request.

Annotations
@JsonAdapter:Factory
deprecatedback to summary
private Boolean deprecated

Deprecated

Use tags instead if supported.

Indicates if this item is deprecated.

Since 3.8.0

Annotations
@Deprecated
detailback to summary
private String detail

A human-readable string with additional information about this item, like type or symbol information.

documentationback to summary
private Either<String, MarkupContent> documentation

A human-readable string that represents a doc-comment.

filterTextback to summary
private String filterText

A string that should be used when filtering a set of completion items. When omitted or empty, the label is used as the filter text for this item.

insertTextback to summary
private String insertText

A string that should be inserted a document when selecting this completion. When omitted or empty, the label is used as the insert text for this item.

insertTextFormatback to summary
private InsertTextFormat insertTextFormat

The format of the insert text. The format applies to both the insertText property and the newText property of a provided textEdit. If omitted, defaults to InsertTextFormat#PlainText.

Please note that this doesn't apply to additionalTextEdits.

insertTextModeback to summary
private InsertTextMode insertTextMode

How whitespace and indentation is handled during completion item insertion. If not provided, the client's default value depends on the CompletionCapabilities#insertTextMode client capability.

Since 3.16.0

kindback to summary
private CompletionItemKind kind

The kind of this completion item. Based of the kind an icon is chosen by the editor.

labelback to summary
private String label

The label of this completion item. By default also the text that is inserted when selecting this completion.

If label details are provided, the label itself should be an unqualified name of the completion item.

Annotations
@NonNull
labelDetailsback to summary
private CompletionItemLabelDetails labelDetails

Additional details for the label

Since 3.17.0

preselectback to summary
private Boolean preselect

Select this item when showing.

Note

that only one completion item can be selected and that the tool / client decides which item that is. The rule is that the first item of those that match best is selected.

Since 3.9.0

sortTextback to summary
private String sortText

A string that should be used when comparing this item with other items. When omitted or empty, the label is used as the sort text for this item.

tagsback to summary
private List<CompletionItemTag> tags

Tags for this completion item.

Since 3.15.0

textEditback to summary
private Either<TextEdit, InsertReplaceEdit> textEdit

An edit which is applied to a document when selecting this completion. When an edit is provided the value of insertText is ignored.

Note

The range of the edit must be a single line range and it must contain the position at which completion has been requested.

Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for InsertReplaceEdits via the CompletionItemCapabilities#insertReplaceSupport client capability property.

Note 1: The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested.

Note 2: If an InsertReplaceEdit is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position.

Since 3.16.0 additional type InsertReplaceEdit

Annotations
@JsonAdapter:CompletionItemTextEditTypeAdapter
textEditTextback to summary
private String textEditText

The edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range.

Clients will only honor this property if they opt into completion list item defaults using the capability CompletionListCapabilities#itemDefaults.

If not provided and a list's default range is provided the label property is used as a text.

Since 3.17.0

Constructor Detail

CompletionItemback to summary
public CompletionItem()
CompletionItemback to summary
public CompletionItem(final String label)

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
getAdditionalTextEditsback to summary
public List<TextEdit> getAdditionalTextEdits()

An optional array of additional text edits that are applied when selecting this completion. Edits must not overlap (including the same insert position) with the main edit nor with themselves.

Additional text edits should be used to change text unrelated to the current cursor position (for example adding an import statement at the top of the file if the completion item will insert an unqualified type).

getCommandback to summary
public Command getCommand()

An optional command that is executed after inserting this completion

Note

that additional modifications to the current document should be described with the additionalTextEdits property.

getCommitCharactersback to summary
public List<String> getCommitCharacters()

An optional set of characters that when pressed while this completion is active will accept it first and then type that character

Note

that all commit characters should have length=1 and that superfluous characters will be ignored.

Since 3.2.0

getDataback to summary
public Object getData()

A data entry field that is preserved on a completion item between a completion and a completion resolve request.

getDeprecatedback to summary
public Boolean getDeprecated()

Deprecated

Use tags instead if supported.

Indicates if this item is deprecated.

Since 3.8.0

Annotations
@Deprecated
getDetailback to summary
public String getDetail()

A human-readable string with additional information about this item, like type or symbol information.

getDocumentationback to summary
public Either<String, MarkupContent> getDocumentation()

A human-readable string that represents a doc-comment.

getFilterTextback to summary
public String getFilterText()

A string that should be used when filtering a set of completion items. When omitted or empty, the label is used as the filter text for this item.

getInsertTextback to summary
public String getInsertText()

A string that should be inserted a document when selecting this completion. When omitted or empty, the label is used as the insert text for this item.

getInsertTextFormatback to summary
public InsertTextFormat getInsertTextFormat()

The format of the insert text. The format applies to both the insertText property and the newText property of a provided textEdit. If omitted, defaults to InsertTextFormat#PlainText.

Please note that this doesn't apply to additionalTextEdits.

getInsertTextModeback to summary
public InsertTextMode getInsertTextMode()

How whitespace and indentation is handled during completion item insertion. If not provided, the client's default value depends on the CompletionCapabilities#insertTextMode client capability.

Since 3.16.0

getKindback to summary
public CompletionItemKind getKind()

The kind of this completion item. Based of the kind an icon is chosen by the editor.

getLabelback to summary
public String getLabel()

The label of this completion item. By default also the text that is inserted when selecting this completion.

If label details are provided, the label itself should be an unqualified name of the completion item.

Annotations
@NonNull
getLabelDetailsback to summary
public CompletionItemLabelDetails getLabelDetails()

Additional details for the label

Since 3.17.0

getPreselectback to summary
public Boolean getPreselect()

Select this item when showing.

Note

that only one completion item can be selected and that the tool / client decides which item that is. The rule is that the first item of those that match best is selected.

Since 3.9.0

getSortTextback to summary
public String getSortText()

A string that should be used when comparing this item with other items. When omitted or empty, the label is used as the sort text for this item.

getTagsback to summary
public List<CompletionItemTag> getTags()

Tags for this completion item.

Since 3.15.0

getTextEditback to summary
public Either<TextEdit, InsertReplaceEdit> getTextEdit()

An edit which is applied to a document when selecting this completion. When an edit is provided the value of insertText is ignored.

Note

The range of the edit must be a single line range and it must contain the position at which completion has been requested.

Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for InsertReplaceEdits via the CompletionItemCapabilities#insertReplaceSupport client capability property.

Note 1: The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested.

Note 2: If an InsertReplaceEdit is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position.

Since 3.16.0 additional type InsertReplaceEdit

getTextEditTextback to summary
public String getTextEditText()

The edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range.

Clients will only honor this property if they opt into completion list item defaults using the capability CompletionListCapabilities#itemDefaults.

If not provided and a list's default range is provided the label property is used as a text.

Since 3.17.0

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
setAdditionalTextEditsback to summary
public void setAdditionalTextEdits(final List<TextEdit> additionalTextEdits)

An optional array of additional text edits that are applied when selecting this completion. Edits must not overlap (including the same insert position) with the main edit nor with themselves.

Additional text edits should be used to change text unrelated to the current cursor position (for example adding an import statement at the top of the file if the completion item will insert an unqualified type).

setCommandback to summary
public void setCommand(final Command command)

An optional command that is executed after inserting this completion

Note

that additional modifications to the current document should be described with the additionalTextEdits property.

setCommitCharactersback to summary
public void setCommitCharacters(final List<String> commitCharacters)

An optional set of characters that when pressed while this completion is active will accept it first and then type that character

Note

that all commit characters should have length=1 and that superfluous characters will be ignored.

Since 3.2.0

setDataback to summary
public void setData(final Object data)

A data entry field that is preserved on a completion item between a completion and a completion resolve request.

setDeprecatedback to summary
public void setDeprecated(final Boolean deprecated)

Deprecated

Use tags instead if supported.

Indicates if this item is deprecated.

Since 3.8.0

Annotations
@Deprecated
setDetailback to summary
public void setDetail(final String detail)

A human-readable string with additional information about this item, like type or symbol information.

setDocumentationback to summary
public void setDocumentation(final Either<String, MarkupContent> documentation)

A human-readable string that represents a doc-comment.

setDocumentationback to summary
public void setDocumentation(final String documentation)
setDocumentationback to summary
public void setDocumentation(final MarkupContent documentation)
setFilterTextback to summary
public void setFilterText(final String filterText)

A string that should be used when filtering a set of completion items. When omitted or empty, the label is used as the filter text for this item.

setInsertTextback to summary
public void setInsertText(final String insertText)

A string that should be inserted a document when selecting this completion. When omitted or empty, the label is used as the insert text for this item.

setInsertTextFormatback to summary
public void setInsertTextFormat(final InsertTextFormat insertTextFormat)

The format of the insert text. The format applies to both the insertText property and the newText property of a provided textEdit. If omitted, defaults to InsertTextFormat#PlainText.

Please note that this doesn't apply to additionalTextEdits.

setInsertTextModeback to summary
public void setInsertTextMode(final InsertTextMode insertTextMode)

How whitespace and indentation is handled during completion item insertion. If not provided, the client's default value depends on the CompletionCapabilities#insertTextMode client capability.

Since 3.16.0

setKindback to summary
public void setKind(final CompletionItemKind kind)

The kind of this completion item. Based of the kind an icon is chosen by the editor.

setLabelback to summary
public void setLabel(final String label)

The label of this completion item. By default also the text that is inserted when selecting this completion.

If label details are provided, the label itself should be an unqualified name of the completion item.

setLabelDetailsback to summary
public void setLabelDetails(final CompletionItemLabelDetails labelDetails)

Additional details for the label

Since 3.17.0

setPreselectback to summary
public void setPreselect(final Boolean preselect)

Select this item when showing.

Note

that only one completion item can be selected and that the tool / client decides which item that is. The rule is that the first item of those that match best is selected.

Since 3.9.0

setSortTextback to summary
public void setSortText(final String sortText)

A string that should be used when comparing this item with other items. When omitted or empty, the label is used as the sort text for this item.

setTagsback to summary
public void setTags(final List<CompletionItemTag> tags)

Tags for this completion item.

Since 3.15.0

setTextEditback to summary
public void setTextEdit(final Either<TextEdit, InsertReplaceEdit> textEdit)

An edit which is applied to a document when selecting this completion. When an edit is provided the value of insertText is ignored.

Note

The range of the edit must be a single line range and it must contain the position at which completion has been requested.

Most editors support two different operations when accepting a completion item. One is to insert a completion text and the other is to replace an existing text with a completion text. Since this can usually not be predetermined by a server it can report both ranges. Clients need to signal support for InsertReplaceEdits via the CompletionItemCapabilities#insertReplaceSupport client capability property.

Note 1: The text edit's range as well as both ranges from an insert replace edit must be a [single line] and they must contain the position at which completion has been requested.

Note 2: If an InsertReplaceEdit is returned the edit's insert range must be a prefix of the edit's replace range, that means it must be contained and starting at the same position.

Since 3.16.0 additional type InsertReplaceEdit

setTextEditTextback to summary
public void setTextEditText(final String textEditText)

The edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range.

Clients will only honor this property if they opt into completion list item defaults using the capability CompletionListCapabilities#itemDefaults.

If not provided and a list's default range is provided the label property is used as a text.

Since 3.17.0

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