Documentation

CompletionItem
in package

Table of Contents

Properties

$additionalTextEdits  : array<string|int, TextEdit>|null
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.
$command  : Command|null
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.
$commitCharacters  : array<string|int, string>|null
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.
$data  : mixed
An data entry field that is preserved on a completion item between a completion and a completion resolve request.
$deprecated  : bool|null
Indicates if this item is deprecated.
$detail  : string|null
A human-readable string with additional information about this item, like type or symbol information.
$documentation  : string|null
A human-readable string that represents a doc-comment.
$filterText  : string|null
A string that should be used when filtering a set of completion items. When `falsy` the label is used.
$insertText  : string|null
A string that should be inserted into a document when selecting this completion. When `falsy` the label is used as the insert text for this item.
$insertTextFormat  : int|null
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`.
$insertTextMode  : int|null
How whitespace and indentation is handled during completion item insertion. If not provided the client's default value depends on the `textDocument.completion.insertTextMode` client capability.
$kind  : int|null
The kind of this completion item. Based of the kind an icon is chosen by the editor.
$label  : string
The label of this completion item. By default also the text that is inserted when selecting this completion.
$labelDetails  : CompletionItemLabelDetails|null
Additional details for the label
$preselect  : bool|null
Select this item when showing.
$sortText  : string|null
A string that should be used when comparing this item with other items. When `falsy` the label is used.
$tags  : array<string|int, CompletionItemTag>|null
Tags for this completion item.
$textEdit  : TextEdit|null
An edit which is applied to a document when selecting this completion.

Methods

__construct()  : mixed

Properties

$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.

public array<string|int, TextEdit>|null $additionalTextEdits

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).

$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 Command|null $command

$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 array<string|int, string>|null $commitCharacters

$data

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

public mixed $data

$deprecated

Indicates if this item is deprecated.

Use tags instead if supported.

public bool|null $deprecated

$detail

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

public string|null $detail

$documentation

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

public string|null $documentation

$filterText

A string that should be used when filtering a set of completion items. When `falsy` the label is used.

public string|null $filterText

$insertText

A string that should be inserted into a document when selecting this completion. When `falsy` the label is used as the insert text for this item.

public string|null $insertText

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<cursor position> 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.

$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`.

public int|null $insertTextFormat

Please note that the insertTextFormat doesn't apply to additionalTextEdits.

Tags
see
InsertTextFormat

$insertTextMode

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

public int|null $insertTextMode
Tags
since
3.16.0
since
3.17.0
  • support for textDocument.completion.insertTextMode
see
InsertTextMode

$label

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

public string $label

$preselect

Select this item when showing.

public bool|null $preselect

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.

$sortText

A string that should be used when comparing this item with other items. When `falsy` the label is used.

public string|null $sortText

$textEdit

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

public TextEdit|null $textEdit

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 textDocument.completion.completionItem.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.

Tags
since
3.16.0

additional type InsertReplaceEdit

Methods

__construct()

public __construct([string $label = null ][, int|null $kind = null ][, string|null $detail = null ][, string|null $documentation = null ][, string|null $sortText = null ][, string|null $filterText = null ][, string|null $insertText = null ][, TextEdit|null $textEdit = null ][, array<string|int, TextEdit>|null $additionalTextEdits = null ][, Command|null $command = null ][, mixed|null $data = null ][, int|null $insertTextFormat = null ]) : mixed
Parameters
$label : string = null
$kind : int|null = null
$detail : string|null = null
$documentation : string|null = null
$sortText : string|null = null
$filterText : string|null = null
$insertText : string|null = null
$textEdit : TextEdit|null = null
$additionalTextEdits : array<string|int, TextEdit>|null = null
$command : Command|null = null
$data : mixed|null = null
$insertTextFormat : int|null = null

        
On this page

Search results