Create a new completion context. (Mostly useful for testing completion sources—in the editor, the extension will create these for you.)
The editor state that the completion happens in.
The position at which the completion is happening.
Indicates whether completion was activated explicitly, or
implicitly by typing. The usual way to respond to this is to
only return completions when either there is part of a
completable entity before the cursor, or explicit is true.
Optionalview: EditorViewThe editor view. May be undefined if the context was created
in a situation where there is no such view available, such as
in synchronous updates via
CompletionResult.update
or when called by test code.
ReadonlyexplicitIndicates whether completion was activated explicitly, or
implicitly by typing. The usual way to respond to this is to
only return completions when either there is part of a
completable entity before the cursor, or explicit is true.
ReadonlyposThe position at which the completion is happening.
ReadonlystateThe editor state that the completion happens in.
Optional ReadonlyviewThe editor view. May be undefined if the context was created
in a situation where there is no such view available, such as
in synchronous updates via
CompletionResult.update
or when called by test code.
Yields true when the query has been aborted. Can be useful in asynchronous queries to avoid doing work that will be ignored.
Allows you to register abort handlers, which will be called when the query is aborted.
By default, running queries will not be aborted for regular
typing or backspacing, on the assumption that they are likely to
return a result with a
validFor field that
allows the result to be used after all. Passing onDocChange: true will cause this query to be aborted for any document
change.
Optionaloptions: { onDocChange: boolean }Get the match of the given expression directly before the cursor.
Get the extent, content, and (if there is a token) type of the
token before this.pos.
An instance of this is passed to completion source functions.