Skip to content

Commit

Permalink
feat: DocumentSemanticTokensProvider.legend
Browse files Browse the repository at this point in the history
  • Loading branch information
fannheyward committed Jun 10, 2021
1 parent 29d5927 commit 004ab14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/language-client/semanticTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class SemanticTokensFeature extends TextDocumentFeature<boolean | Semanti
const documentProvider: DocumentSemanticTokensProvider | undefined = fullProvider
? {
onDidChangeSemanticTokens: eventEmitter.event,
legend: options.legend,
provideDocumentSemanticTokens: (document, token) => {
const client = this._client
const middleware = client.clientOptions.middleware! as Middleware & SemanticTokensMiddleware
Expand Down Expand Up @@ -168,6 +169,7 @@ export class SemanticTokensFeature extends TextDocumentFeature<boolean | Semanti
const hasRangeProvider: boolean = options.range === true
const rangeProvider: DocumentRangeSemanticTokensProvider | undefined = hasRangeProvider
? {
legend: options.legend,
provideDocumentRangeSemanticTokens: (document: TextDocument, range: Range, token: CancellationToken) => {
const client = this._client
const middleware = client.clientOptions.middleware! as Middleware & SemanticTokensMiddleware
Expand Down
5 changes: 4 additions & 1 deletion src/provider/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CallHierarchyIncomingCall, CallHierarchyItem, CallHierarchyOutgoingCall, CancellationToken, CodeAction, CodeActionContext, CodeActionKind, CodeLens, Color, ColorInformation, ColorPresentation, Command, CompletionContext, CompletionItem, CompletionList, Definition, DefinitionLink, DocumentHighlight, DocumentLink, DocumentSymbol, Event, FoldingRange, FormattingOptions, Hover, LinkedEditingRanges, Location, Position, Range, SelectionRange, SemanticTokens, SemanticTokensDelta, SignatureHelp, SignatureHelpContext, SymbolInformation, TextEdit, WorkspaceEdit } from 'vscode-languageserver-protocol'
import { CallHierarchyIncomingCall, CallHierarchyItem, CallHierarchyOutgoingCall, CancellationToken, CodeAction, CodeActionContext, CodeActionKind, CodeLens, Color, ColorInformation, ColorPresentation, Command, CompletionContext, CompletionItem, CompletionList, Definition, DefinitionLink, DocumentHighlight, DocumentLink, DocumentSymbol, Event, FoldingRange, FormattingOptions, Hover, LinkedEditingRanges, Location, Position, Range, SelectionRange, SemanticTokens, SemanticTokensDelta, SemanticTokensLegend, SignatureHelp, SignatureHelpContext, SymbolInformation, TextEdit, WorkspaceEdit } from 'vscode-languageserver-protocol'
import { TextDocument } from 'vscode-languageserver-textdocument'
import { URI } from 'vscode-uri'

Expand Down Expand Up @@ -695,6 +695,8 @@ export interface DocumentSemanticTokensProvider {
// TODO: SemantiTokens
onDidChangeSemanticTokens?: Event<void>

legend: SemanticTokensLegend

/**
* Tokens in a file are represented as an array of integers. The position of each token is expressed relative to
* the token before it, because most tokens remain stable relative to each other when edits are made in a file.
Expand Down Expand Up @@ -794,6 +796,7 @@ export interface DocumentSemanticTokensProvider {
* semantic tokens.
*/
export interface DocumentRangeSemanticTokensProvider {
legend: SemanticTokensLegend
/**
* @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens).
*/
Expand Down

0 comments on commit 004ab14

Please sign in to comment.