Variables

read onlyonDidChangeDiagnostics:Event<DiagnosticChangeEvent>

An {@link Event} which fires when the global set of diagnostics changes. This is newly added and removed diagnostics.

Methods

createDiagnosticCollection(?name:String):DiagnosticCollection

Create a diagnostics collection.

@link DiagnosticCollection.name name} of the collection.

Parameters:

name

The {

Returns:

A new diagnostic collection.

getDiagnostics():Array<VscodeLanguagesGetDiagnosticsReturn>

getDiagnostics(resource:Uri):Array<Diagnostic>

Get all diagnostics for a given resource.

@link Diagnostic diagnostics} objects or an empty array.

OR

Get all diagnostics.

Parameters:

resource

A resource

Returns:

An array of uri-diagnostics tuples or an empty array.

getLanguages():Thenable<Array<String>>

Return the identifiers of all known languages.

Returns:

Promise resolving to an array of identifier strings.

match(selector:DocumentSelector, document:TextDocument):Float

Compute the match between a document {@link DocumentSelector selector} and a document. Values greater than zero mean the selector matches the document.

A match is computed according to these rules: 1. When {@linkcode DocumentSelector} is an array, compute the match for each contained DocumentFilter or language identifier and take the maximum value. 2. A string will be desugared to become the language-part of a {@linkcode DocumentFilter}, so "fooLang" is like { language: "fooLang" }. 3. A {@linkcode DocumentFilter} will be matched against the document by comparing its parts with the document. The following rules apply: 1. When the DocumentFilter is empty ({}) the result is 0 2. When scheme, language, or pattern are defined but one doesn’t match, the result is 0 3. Matching against * gives a score of 5, matching via equality or via a glob-pattern gives a score of 10 4. The result is the maximum value of each match

Samples:

// default document from disk (file-scheme)
doc.uri; //'file:///my/file.js'
doc.languageId; // 'javascript'
match('javascript', doc); // 10;
match({language: 'javascript'}, doc); // 10;
match({language: 'javascript', scheme: 'file'}, doc); // 10;
match('*', doc); // 5
match('fooLang', doc); // 0
match(['fooLang', '*'], doc); // 5

// virtual document, e.g. from git-index
doc.uri; // 'git:/my/file.js'
doc.languageId; // 'javascript'
match('javascript', doc); // 10;
match({language: 'javascript', scheme: 'git'}, doc); // 10;
match('*', doc); // 5

Parameters:

selector

A document selector.

document

A text document.

Returns:

A number >0 when the selector matches and 0 when the selector does not match.

registerCallHierarchyProvider(selector:DocumentSelector, provider:CallHierarchyProvider):Disposable

Register a call hierarchy provider.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A call hierarchy provider.

Returns:

A {

registerCodeActionsProvider<T>(selector:DocumentSelector, provider:CodeActionProvider<T>, ?metadata:CodeActionProviderMetadata):Disposable

Register a code action provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A code action provider.

metadata

Metadata about the kind of code actions the provider provides.

Returns:

A {

registerCodeLensProvider<T>(selector:DocumentSelector, provider:CodeLensProvider<T>):Disposable

Register a code lens provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A code lens provider.

Returns:

A {

registerColorProvider(selector:DocumentSelector, provider:DocumentColorProvider):Disposable

Register a color provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A color provider.

Returns:

A {

registerCompletionItemProvider<T>(selector:DocumentSelector, provider:CompletionItemProvider<T>, triggerCharacters:Rest<String>):Disposable

Register a completion provider.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and groups of equal score are sequentially asked for completion items. The process stops when one or many providers of a group return a result. A failing provider (rejected promise or exception) will not fail the whole operation.

A completion item provider can be associated with a set of triggerCharacters. When trigger characters are being typed, completions are requested but only from providers that registered the typed character. Because of that trigger characters should be different than {@link LanguageConfiguration.wordPattern word characters}, a common trigger character is . to trigger member completions.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A completion provider.

triggerCharacters

Trigger completion when the user types one of the characters.

Returns:

A {

registerDeclarationProvider(selector:DocumentSelector, provider:DeclarationProvider):Disposable

Register a declaration provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A declaration provider.

Returns:

A {

registerDefinitionProvider(selector:DocumentSelector, provider:DefinitionProvider):Disposable

Register a definition provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A definition provider.

Returns:

A {

registerDocumentFormattingEditProvider(selector:DocumentSelector, provider:DocumentFormattingEditProvider):Disposable

Register a formatting provider for a document.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A document formatting edit provider.

Returns:

A {

registerDocumentHighlightProvider(selector:DocumentSelector, provider:DocumentHighlightProvider):Disposable

Register a document highlight provider.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and groups sequentially asked for document highlights. The process stops when a provider returns a non-falsy or non-failure result.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A document highlight provider.

Returns:

A {

registerDocumentLinkProvider<T>(selector:DocumentSelector, provider:DocumentLinkProvider<T>):Disposable

Register a document link provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A document link provider.

Returns:

A {

registerDocumentRangeFormattingEditProvider(selector:DocumentSelector, provider:DocumentRangeFormattingEditProvider):Disposable

Register a formatting provider for a document range.

Note: A document range provider is also a {@link DocumentFormattingEditProvider document formatter} which means there is no need to {@link languages.registerDocumentFormattingEditProvider register} a document formatter when also registering a range provider.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A document range formatting edit provider.

Returns:

A {

registerDocumentRangeSemanticTokensProvider(selector:DocumentSelector, provider:DocumentRangeSemanticTokensProvider, legend:SemanticTokensLegend):Disposable

Register a semantic tokens provider for a document range.

Note: If a document has both a DocumentSemanticTokensProvider and a DocumentRangeSemanticTokensProvider, the range provider will be invoked only initially, for the time in which the full document provider takes to resolve the first request. Once the full document provider resolves the first request, the semantic tokens provided via the range provider will be discarded and from that point forward, only the document provider will be used.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A document range semantic tokens provider.

Returns:

A {

registerDocumentSemanticTokensProvider(selector:DocumentSelector, provider:DocumentSemanticTokensProvider, legend:SemanticTokensLegend):Disposable

Register a semantic tokens provider for a whole document.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A document semantic tokens provider.

Returns:

A {

registerDocumentSymbolProvider(selector:DocumentSelector, provider:DocumentSymbolProvider, ?metaData:DocumentSymbolProviderMetadata):Disposable

Register a document symbol provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A document symbol provider.

metaData

metadata about the provider

Returns:

A {

registerEvaluatableExpressionProvider(selector:DocumentSelector, provider:EvaluatableExpressionProvider):Disposable

Register a provider that locates evaluatable expressions in text documents. The editor will evaluate the expression in the active debug session and will show the result in the debug hover.

If multiple providers are registered for a language an arbitrary provider will be used.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

An evaluatable expression provider.

Returns:

A {

registerFoldingRangeProvider(selector:DocumentSelector, provider:FoldingRangeProvider):Disposable

Register a folding range provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. If multiple folding ranges start at the same position, only the range of the first registered provider is used. If a folding range overlaps with an other range that has a smaller position, it is also ignored.

A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A folding range provider.

Returns:

A {

registerHoverProvider(selector:DocumentSelector, provider:HoverProvider):Disposable

Register a hover provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A hover provider.

Returns:

A {

registerImplementationProvider(selector:DocumentSelector, provider:ImplementationProvider):Disposable

Register an implementation provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

An implementation provider.

Returns:

A {

registerInlineValuesProvider(selector:DocumentSelector, provider:InlineValuesProvider):Disposable

Register a provider that returns data for the debugger's 'inline value' feature. Whenever the generic debugger has stopped in a source file, providers registered for the language of the file are called to return textual data that will be shown in the editor at the end of lines.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

An inline values provider.

Returns:

A {

registerLinkedEditingRangeProvider(selector:DocumentSelector, provider:LinkedEditingRangeProvider):Disposable

Register a linked editing range provider.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and the best-matching provider that has a result is used. Failure of the selected provider will cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A linked editing range provider.

Returns:

A {

registerOnTypeFormattingEditProvider(selector:DocumentSelector, provider:OnTypeFormattingEditProvider, firstTriggerCharacter:String, moreTriggerCharacter:Rest<String>):Disposable

Register a formatting provider that works on type. The provider is active when the user enables the setting editor.formatOnType.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

An on type formatting edit provider.

firstTriggerCharacter

A character on which formatting should be triggered, like }.

moreTriggerCharacter

More trigger characters.

Returns:

A {

registerReferenceProvider(selector:DocumentSelector, provider:ReferenceProvider):Disposable

Register a reference provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A reference provider.

Returns:

A {

registerRenameProvider(selector:DocumentSelector, provider:RenameProvider):Disposable

Register a rename provider.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and asked in sequence. The first provider producing a result defines the result of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A rename provider.

Returns:

A {

registerSelectionRangeProvider(selector:DocumentSelector, provider:SelectionRangeProvider):Disposable

Register a selection range provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A selection range provider.

Returns:

A {

registerSignatureHelpProvider(selector:DocumentSelector, provider:SignatureHelpProvider, metadata:SignatureHelpProviderMetadata):Disposable

registerSignatureHelpProvider(selector:DocumentSelector, provider:SignatureHelpProvider, triggerCharacters:Rest<String>):Disposable

Register a signature help provider.

Multiple providers can be registered for a language. In that case providers are sorted by their {@link languages.match score} and called sequentially until a provider returns a valid result.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A signature help provider.

triggerCharacters

Trigger signature help when the user types one of the characters, like , or (.

metadata

Information about the provider.

Returns:

A {

registerTypeDefinitionProvider(selector:DocumentSelector, provider:TypeDefinitionProvider):Disposable

Register a type definition provider.

Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

selector

A selector that defines the documents this provider is applicable to.

provider

A type definition provider.

Returns:

A {

registerWorkspaceSymbolProvider<T>(provider:WorkspaceSymbolProvider<T>):Disposable

Register a workspace symbol provider.

Multiple providers can be registered. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.

@link Disposable} that unregisters this provider when being disposed.

Parameters:

provider

A workspace symbol provider.

Returns:

A {

setLanguageConfiguration(language:String, configuration:LanguageConfiguration):Disposable

Set a {@link LanguageConfiguration language configuration} for a language.

@link Disposable} that unsets this configuration.

Parameters:

language

A language identifier like typescript.

configuration

Language configuration.

Returns:

A {

setTextDocumentLanguage(document:TextDocument, languageId:String):Thenable<TextDocument>

Set (and change) the {@link TextDocument.languageId language} that is associated with the given document.

Note that calling this function will trigger the {@linkcode workspace.onDidCloseTextDocument onDidCloseTextDocument} event followed by the {@linkcode workspace.onDidOpenTextDocument onDidOpenTextDocument} event.

Parameters:

document

The document which language is to be changed

languageId

The new language identifier.

Returns:

A thenable that resolves with the updated document.