public final class Completion extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Completion.Context
Contains additional information about the context in which a request for
collections completions is triggered.
|
static class |
Completion.Kind
The kind of a completion.
|
static class |
Completion.Tag
Completion item tags are extra annotations that tweak the rendering of a
completion.
|
static class |
Completion.TextFormat
Defines whether the insert text in a completion item should be interpreted
as plain text or a snippet.
|
static class |
Completion.TriggerKind
Specifies how a completion was triggered.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
collect(Document doc,
int offset,
Completion.Context context,
java.util.function.Consumer<Completion> consumer)
Computes and collects completions for a document at a given offset.
|
CompletableFuture<List<TextEdit>> |
getAdditionalTextEdits()
A list of additional text edits that are applied when selecting this
completion.
|
Command |
getCommand()
An optional command that is executed after inserting this completion.
|
List<Character> |
getCommitCharacters()
A list of characters that when pressed while this completion is
active will accept it first and then type that character.
|
CompletableFuture<String> |
getDetail()
A human-readable string with additional information
about this completion, like type or symbol information.
|
CompletableFuture<String> |
getDocumentation()
A human-readable string that represents a doc-comment.
|
String |
getFilterText()
A string that should be used when filtering a set of completions.
|
String |
getInsertText()
A string that should be inserted into a document when selecting
this completion.
|
Completion.TextFormat |
getInsertTextFormat()
The format of the insert text.
|
Completion.Kind |
getKind()
The kind of this completion.
|
String |
getLabel()
The label of this completion.
|
String |
getLabelDescription()
An optional string which is rendered less prominently after
label detail . |
String |
getLabelDetail()
An optional string which is rendered less prominently directly after
label , without any spacing. |
String |
getSortText()
A string that should be used when comparing this completion with other
completions.
|
List<Completion.Tag> |
getTags()
Tags for this completion.
|
TextEdit |
getTextEdit()
An edit which is applied to a document when selecting this completion.
|
boolean |
isPreselect()
Select this completion when showing.
|
@NonNull public String getLabel()
@CheckForNull public String getLabelDetail()
label
, without any spacing. Should be
used for function signatures or type annotations.@CheckForNull public String getLabelDescription()
label detail
. Should be used for fully qualified
names or file path.@CheckForNull public Completion.Kind getKind()
@CheckForNull public List<Completion.Tag> getTags()
@CheckForNull public CompletableFuture<String> getDetail()
@CheckForNull public CompletableFuture<String> getDocumentation()
public boolean isPreselect()
@CheckForNull public String getSortText()
null
the label is used as the sort text.@CheckForNull public String getFilterText()
null
the label is used as the filter.@CheckForNull public String getInsertText()
null
the label is used as the insert text.@CheckForNull public Completion.TextFormat getInsertTextFormat()
insertText
property and the newText
property of a provided
textEdit
. If omitted defaults to Completion.TextFormat.PlainText
.@CheckForNull public TextEdit getTextEdit()
insertText
is ignored.
The range of the edit must be a single line range and it must
contain the position at which completion has been requested.@CheckForNull public Command getCommand()
@CheckForNull public CompletableFuture<List<TextEdit>> getAdditionalTextEdits()
@CheckForNull public List<Character> getCommitCharacters()
public static boolean collect(@NonNull Document doc, int offset, @NullAllowed Completion.Context context, @NonNull java.util.function.Consumer<Completion> consumer)
// Compute and collect completions for a document at a given offset boolean isComplete =Completion
.collect(doc, offset, null, completion -> { // completion should never be 'null' assertNotNull(completion); // getting completion 'label'String
label = completion.getLabel(); assertEquals("label", label); // getting optional completion 'detail'CompletableFuture
<String
> detail = completion.getDetail(); // check for 'null' value if (detail != null) { // value should be already computed assertTrue(detail.isDone()); // getting the valueString
value = detail.getNow(null); assertEquals("detail", value); } // getting optional completion 'documentation'CompletableFuture
<String
> documentation = completion.getDocumentation(); // check for 'null' value if (documentation != null) { // value computation should be deferred assertFalse(documentation.isDone()); // getting the value try {String
value = documentation.get(); assertEquals("documentation", value); } catch (Exception
ex) {Exceptions
.printStackTrace(ex); } } });
doc
- a text documentoffset
- an offset inside the text documentcontext
- an optional completion contextconsumer
- an operation accepting collected completionsfalse
,
further typing should result in subsequent calls to this method to recompute
the completions.