Class CompletionItem
- java.lang.Object
-
- org.eclipse.lsp4j.CompletionItem
-
public class CompletionItem extends java.lang.ObjectThe 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.
-
-
Constructor Summary
Constructors Constructor Description CompletionItem()CompletionItem(java.lang.String label)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.util.List<TextEdit>getAdditionalTextEdits()An optional array of additional text edits that are applied when selecting this completion.CommandgetCommand()An optional command that is executed after inserting this completion.java.util.List<java.lang.String>getCommitCharacters()An optional set of characters that when pressed while this completion is active will accept it first and then type that character.java.lang.ObjectgetData()A data entry field that is preserved on a completion item between a completion and a completion resolve request.java.lang.BooleangetDeprecated()Deprecated.Usetagsinstead if supported.java.lang.StringgetDetail()A human-readable string with additional information about this item, like type or symbol information.org.eclipse.lsp4j.jsonrpc.messages.Either<java.lang.String,MarkupContent>getDocumentation()A human-readable string that represents a doc-comment.java.lang.StringgetFilterText()A string that should be used when filtering a set of completion items.java.lang.StringgetInsertText()A string that should be inserted a document when selecting this completion.InsertTextFormatgetInsertTextFormat()The format of the insert text.InsertTextModegetInsertTextMode()How whitespace and indentation is handled during completion item insertion.CompletionItemKindgetKind()The kind of this completion item.java.lang.StringgetLabel()The label of this completion item.CompletionItemLabelDetailsgetLabelDetails()Additional details for the labeljava.lang.BooleangetPreselect()Select this item when showing.java.lang.StringgetSortText()A string that should be used when comparing this item with other items.java.util.List<CompletionItemTag>getTags()Tags for this completion item.org.eclipse.lsp4j.jsonrpc.messages.Either<TextEdit,InsertReplaceEdit>getTextEdit()An edit which is applied to a document when selecting this completion.java.lang.StringgetTextEditText()The edit text used if the completion item is part of a CompletionList and CompletionList defines an item default for the text edit range.inthashCode()voidsetAdditionalTextEdits(java.util.List<TextEdit> additionalTextEdits)An optional array of additional text edits that are applied when selecting this completion.voidsetCommand(Command command)An optional command that is executed after inserting this completion.voidsetCommitCharacters(java.util.List<java.lang.String> commitCharacters)An optional set of characters that when pressed while this completion is active will accept it first and then type that character.voidsetData(java.lang.Object data)A data entry field that is preserved on a completion item between a completion and a completion resolve request.voidsetDeprecated(java.lang.Boolean deprecated)Deprecated.Usetagsinstead if supported.voidsetDetail(java.lang.String detail)A human-readable string with additional information about this item, like type or symbol information.voidsetDocumentation(java.lang.String documentation)voidsetDocumentation(org.eclipse.lsp4j.jsonrpc.messages.Either<java.lang.String,MarkupContent> documentation)A human-readable string that represents a doc-comment.voidsetDocumentation(MarkupContent documentation)voidsetFilterText(java.lang.String filterText)A string that should be used when filtering a set of completion items.voidsetInsertText(java.lang.String insertText)A string that should be inserted a document when selecting this completion.voidsetInsertTextFormat(InsertTextFormat insertTextFormat)The format of the insert text.voidsetInsertTextMode(InsertTextMode insertTextMode)How whitespace and indentation is handled during completion item insertion.voidsetKind(CompletionItemKind kind)The kind of this completion item.voidsetLabel(java.lang.String label)The label of this completion item.voidsetLabelDetails(CompletionItemLabelDetails labelDetails)Additional details for the labelvoidsetPreselect(java.lang.Boolean preselect)Select this item when showing.voidsetSortText(java.lang.String sortText)A string that should be used when comparing this item with other items.voidsetTags(java.util.List<CompletionItemTag> tags)Tags for this completion item.voidsetTextEdit(org.eclipse.lsp4j.jsonrpc.messages.Either<TextEdit,InsertReplaceEdit> textEdit)An edit which is applied to a document when selecting this completion.voidsetTextEditText(java.lang.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.java.lang.StringtoString()
-
-
-
Method Detail
-
getLabel
public java.lang.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.
-
setLabel
public void setLabel(java.lang.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.
-
getLabelDetails
public CompletionItemLabelDetails getLabelDetails()
Additional details for the labelSince 3.17.0
-
setLabelDetails
public void setLabelDetails(CompletionItemLabelDetails labelDetails)
Additional details for the labelSince 3.17.0
-
getKind
public CompletionItemKind getKind()
The kind of this completion item. Based of the kind an icon is chosen by the editor.
-
setKind
public void setKind(CompletionItemKind kind)
The kind of this completion item. Based of the kind an icon is chosen by the editor.
-
getTags
public java.util.List<CompletionItemTag> getTags()
Tags for this completion item.Since 3.15.0
-
setTags
public void setTags(java.util.List<CompletionItemTag> tags)
Tags for this completion item.Since 3.15.0
-
getDetail
public java.lang.String getDetail()
A human-readable string with additional information about this item, like type or symbol information.
-
setDetail
public void setDetail(java.lang.String detail)
A human-readable string with additional information about this item, like type or symbol information.
-
getDocumentation
public org.eclipse.lsp4j.jsonrpc.messages.Either<java.lang.String,MarkupContent> getDocumentation()
A human-readable string that represents a doc-comment.
-
setDocumentation
public void setDocumentation(org.eclipse.lsp4j.jsonrpc.messages.Either<java.lang.String,MarkupContent> documentation)
A human-readable string that represents a doc-comment.
-
setDocumentation
public void setDocumentation(java.lang.String documentation)
-
setDocumentation
public void setDocumentation(MarkupContent documentation)
-
getDeprecated
@Deprecated public java.lang.Boolean getDeprecated()
Deprecated.Usetagsinstead if supported.Indicates if this item is deprecated.Since 3.8.0
-
setDeprecated
@Deprecated public void setDeprecated(java.lang.Boolean deprecated)
Deprecated.Usetagsinstead if supported.Indicates if this item is deprecated.Since 3.8.0
-
getPreselect
public java.lang.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
-
setPreselect
public void setPreselect(java.lang.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
-
getSortText
public java.lang.String getSortText()
A string that should be used when comparing this item with other items. When omitted or empty, thelabelis used as the sort text for this item.
-
setSortText
public void setSortText(java.lang.String sortText)
A string that should be used when comparing this item with other items. When omitted or empty, thelabelis used as the sort text for this item.
-
getFilterText
public java.lang.String getFilterText()
A string that should be used when filtering a set of completion items. When omitted or empty, thelabelis used as the filter text for this item.
-
setFilterText
public void setFilterText(java.lang.String filterText)
A string that should be used when filtering a set of completion items. When omitted or empty, thelabelis used as the filter text for this item.
-
getInsertText
public java.lang.String getInsertText()
A string that should be inserted a document when selecting this completion. When omitted or empty, thelabelis used as the insert text for this item.
-
setInsertText
public void setInsertText(java.lang.String insertText)
A string that should be inserted a document when selecting this completion. When omitted or empty, thelabelis used as the insert text for this item.
-
getInsertTextFormat
public InsertTextFormat getInsertTextFormat()
The format of the insert text. The format applies to both theinsertTextproperty and thenewTextproperty of a providedtextEdit. If omitted, defaults toInsertTextFormat.PlainText.Please note that this doesn't apply to
additionalTextEdits.
-
setInsertTextFormat
public void setInsertTextFormat(InsertTextFormat insertTextFormat)
The format of the insert text. The format applies to both theinsertTextproperty and thenewTextproperty of a providedtextEdit. If omitted, defaults toInsertTextFormat.PlainText.Please note that this doesn't apply to
additionalTextEdits.
-
getInsertTextMode
public InsertTextMode getInsertTextMode()
How whitespace and indentation is handled during completion item insertion. If not provided, the client's default value depends on theCompletionCapabilities.insertTextModeclient capability.Since 3.16.0
-
setInsertTextMode
public void setInsertTextMode(InsertTextMode insertTextMode)
How whitespace and indentation is handled during completion item insertion. If not provided, the client's default value depends on theCompletionCapabilities.insertTextModeclient capability.Since 3.16.0
-
getTextEdit
public org.eclipse.lsp4j.jsonrpc.messages.Either<TextEdit,InsertReplaceEdit> getTextEdit()
An edit which is applied to a document when selecting this completion. When an edit is provided the value ofinsertTextis 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 theCompletionItemCapabilities.insertReplaceSupportclient 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
InsertReplaceEditis 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
-
setTextEdit
public void setTextEdit(org.eclipse.lsp4j.jsonrpc.messages.Either<TextEdit,InsertReplaceEdit> textEdit)
An edit which is applied to a document when selecting this completion. When an edit is provided the value ofinsertTextis 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 theCompletionItemCapabilities.insertReplaceSupportclient 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
InsertReplaceEditis 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
-
getTextEditText
public java.lang.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
-
setTextEditText
public void setTextEditText(java.lang.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
-
getAdditionalTextEdits
public java.util.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).
-
setAdditionalTextEdits
public void setAdditionalTextEdits(java.util.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).
-
getCommitCharacters
public java.util.List<java.lang.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 havelength=1and that superfluous characters will be ignored.Since 3.2.0
-
setCommitCharacters
public void setCommitCharacters(java.util.List<java.lang.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 havelength=1and that superfluous characters will be ignored.Since 3.2.0
-
getCommand
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 theadditionalTextEditsproperty.
-
setCommand
public void setCommand(Command command)
An optional command that is executed after inserting this completion. Note that additional modifications to the current document should be described with theadditionalTextEditsproperty.
-
getData
public java.lang.Object getData()
A data entry field that is preserved on a completion item between a completion and a completion resolve request.
-
setData
public void setData(java.lang.Object data)
A data entry field that is preserved on a completion item between a completion and a completion resolve request.
-
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
-
-