Class CompletionItem

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

public class CompletionItem extends JSONBase
A completion item represents a text snippet that is proposed to complete text that is being typed.
  • Method Details

    • getLabel

      public String getLabel()
      The label of this completion item. By default also the text that is inserted when selecting this completion.
    • setLabel

      public CompletionItem setLabel(String label)
    • getKind

      public CompletionItemKind getKind()
      The kind of this completion item. Based of the kind an icon is chosen by the editor.
    • setKind

      public CompletionItem setKind(CompletionItemKind kind)
    • getTags

      public List<CompletionItemTag> getTags()
      Tags for this completion item.
      Since:
      3.15.0
    • setTags

      public CompletionItem setTags(List<CompletionItemTag> tags)
    • getDetail

      public String getDetail()
      A human-readable string with additional information about this item, like type or symbol information.
    • setDetail

      public CompletionItem setDetail(String detail)
    • getDocumentation

      public Object getDocumentation()
      A human-readable string that represents a doc-comment.
    • setDocumentation

      public CompletionItem setDocumentation(Object documentation)
    • getDeprecated

      @Deprecated public Boolean getDeprecated()
      Deprecated.
      Use `tags` instead.
      Indicates if this item is deprecated.
    • setDeprecated

      public CompletionItem setDeprecated(Boolean deprecated)
    • getPreselect

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

      public CompletionItem setPreselect(Boolean preselect)
    • getSortText

      public String getSortText()
      A string that should be used when comparing this item with other items. When `falsy` the [label](#CompletionItem.label) is used.
    • setSortText

      public CompletionItem setSortText(String sortText)
    • getFilterText

      public String getFilterText()
      A string that should be used when filtering a set of completion items. When `falsy` the [label](#CompletionItem.label) is used.
    • setFilterText

      public CompletionItem setFilterText(String filterText)
    • getInsertText

      public String getInsertText()
      A string that should be inserted into a document when selecting this completion. When `falsy` the [label](#CompletionItem.label) is used. The `insertText` is subject to interpretation by the client side. Some tools might not take the string literally. For example VS Code when code complete is requested in this example `con` and a completion item with an `insertText` of `console` is provided it will only insert `sole`. Therefore it is recommended to use `textEdit` instead since it avoids additional client side interpretation.
    • setInsertText

      public CompletionItem setInsertText(String insertText)
    • 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 ommitted defaults to `InsertTextFormat.PlainText`.
    • setInsertTextFormat

      public CompletionItem setInsertTextFormat(InsertTextFormat insertTextFormat)
    • getTextEdit

      public TextEdit getTextEdit()
      An [edit](#TextEdit) which is applied to a document when selecting this completion. When an edit is provided the value of [insertText](#CompletionItem.insertText) is ignored. *Note:* The text edit's range must be a [single line] and it must contain the position at which completion has been requested.
    • setTextEdit

      public CompletionItem setTextEdit(TextEdit textEdit)
    • getAdditionalTextEdits

      public List<TextEdit> getAdditionalTextEdits()
      An optional array of additional [text edits](#TextEdit) that are applied when selecting this completion. Edits must not overlap (including the same insert position) with the main [edit](#CompletionItem.textEdit) 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 CompletionItem setAdditionalTextEdits(List<TextEdit> additionalTextEdits)
    • getCommitCharacters

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

      public CompletionItem setCommitCharacters(List<String> commitCharacters)
    • getCommand

      public Command getCommand()
      An optional [command](#Command) that is executed *after* inserting this completion. *Note* that additional modifications to the current document should be described with the [additionalTextEdits](#CompletionItem.additionalTextEdits)-property.
    • setCommand

      public CompletionItem setCommand(Command command)
    • getData

      public Object getData()
      An data entry field that is preserved on a completion item between a [CompletionRequest](#CompletionRequest) and a [CompletionResolveRequest] (#CompletionResolveRequest).
    • setData

      public CompletionItem setData(Object data)
    • equals

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

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

      public static CompletionItem create(String label)
      Create a completion item and seed it with a label.
      Parameters:
      label - The completion item's label