Class CompletionItem


  • public class CompletionItem
    extends java.lang.Object
    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.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.util.List<TextEdit> getAdditionalTextEdits()
      An optional array of additional text edits that are applied when selecting this completion.
      Command getCommand()
      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.Object getData()
      A data entry field that is preserved on a completion item between a completion and a completion resolve request.
      java.lang.Boolean getDeprecated()
      Deprecated.
      Use tags instead if supported.
      java.lang.String getDetail()
      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.String getFilterText()
      A string that should be used when filtering a set of completion items.
      java.lang.String getInsertText()
      A string that should be inserted a document when selecting this completion.
      InsertTextFormat getInsertTextFormat()
      The format of the insert text.
      InsertTextMode getInsertTextMode()
      How whitespace and indentation is handled during completion item insertion.
      CompletionItemKind getKind()
      The kind of this completion item.
      java.lang.String getLabel()
      The label of this completion item.
      CompletionItemLabelDetails getLabelDetails()
      Additional details for the label
      java.lang.Boolean getPreselect()
      Select this item when showing.
      java.lang.String getSortText()
      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.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.
      int hashCode()  
      void setAdditionalTextEdits​(java.util.List<TextEdit> additionalTextEdits)
      An optional array of additional text edits that are applied when selecting this completion.
      void setCommand​(Command command)
      An optional command that is executed after inserting this completion.
      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.
      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.
      void setDeprecated​(java.lang.Boolean deprecated)
      Deprecated.
      Use tags instead if supported.
      void setDetail​(java.lang.String detail)
      A human-readable string with additional information about this item, like type or symbol information.
      void setDocumentation​(java.lang.String documentation)  
      void setDocumentation​(org.eclipse.lsp4j.jsonrpc.messages.Either<java.lang.String,​MarkupContent> documentation)
      A human-readable string that represents a doc-comment.
      void setDocumentation​(MarkupContent documentation)  
      void setFilterText​(java.lang.String filterText)
      A string that should be used when filtering a set of completion items.
      void setInsertText​(java.lang.String insertText)
      A string that should be inserted a document when selecting this completion.
      void setInsertTextFormat​(InsertTextFormat insertTextFormat)
      The format of the insert text.
      void setInsertTextMode​(InsertTextMode insertTextMode)
      How whitespace and indentation is handled during completion item insertion.
      void setKind​(CompletionItemKind kind)
      The kind of this completion item.
      void setLabel​(java.lang.String label)
      The label of this completion item.
      void setLabelDetails​(CompletionItemLabelDetails labelDetails)
      Additional details for the label
      void setPreselect​(java.lang.Boolean preselect)
      Select this item when showing.
      void setSortText​(java.lang.String sortText)
      A string that should be used when comparing this item with other items.
      void setTags​(java.util.List<CompletionItemTag> tags)
      Tags for this completion item.
      void setTextEdit​(org.eclipse.lsp4j.jsonrpc.messages.Either<TextEdit,​InsertReplaceEdit> textEdit)
      An edit which is applied to a document when selecting this completion.
      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.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CompletionItem

        public CompletionItem()
      • CompletionItem

        public CompletionItem​(java.lang.String label)
    • 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.

      • setLabelDetails

        public void setLabelDetails​(CompletionItemLabelDetails labelDetails)
        Additional details for the label

        Since 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.
        Use tags instead if supported.
        Indicates if this item is deprecated.

        Since 3.8.0

      • setDeprecated

        @Deprecated
        public void setDeprecated​(java.lang.Boolean deprecated)
        Deprecated.
        Use tags instead 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, the label is 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, the label is 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, the label is 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, the label is 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, the label is 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, the label is used as the insert text for this item.
      • getInsertTextFormat

        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.

      • setInsertTextFormat

        public void setInsertTextFormat​(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.

      • getInsertTextMode

        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

      • 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 the CompletionCapabilities.insertTextMode client 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 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

      • 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 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

      • 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 have length=1 and 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 have length=1 and 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 the additionalTextEdits property.
      • 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 the additionalTextEdits property.
      • 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:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object