File tree 4 files changed +9
-12
lines changed
4 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export interface LanguageMode {
74
74
getColorPresentations ?( document : TextDocument , color : Color , range : Range ) : ColorPresentation [ ] ;
75
75
getFoldingRanges ?( document : TextDocument ) : FoldingRange [ ] ;
76
76
getRenameFileEdit ?( renames : FileRename ) : TextDocumentEdit [ ] ;
77
- getSemanticTokens ?( document : TextDocument , range ?: Range ) : SemanticTokenData [ ] | null ;
77
+ getSemanticTokens ?( document : TextDocument , range ?: Range ) : SemanticTokenData [ ] ;
78
78
79
79
onDocumentChanged ?( filePath : string ) : void ;
80
80
onDocumentRemoved ( document : TextDocument ) : void ;
Original file line number Diff line number Diff line change @@ -804,8 +804,8 @@ export async function getJavascriptMode(
804
804
getSemanticTokens ( doc : TextDocument , range ?: Range ) {
805
805
const { scriptDoc, service } = updateCurrentVueTextDocument ( doc ) ;
806
806
const scriptText = scriptDoc . getText ( ) ;
807
- if ( ! range && scriptText . trim ( ) . length > SEMANTIC_TOKEN_CONTENT_LENGTH_LIMIT ) {
808
- return null ;
807
+ if ( scriptText . trim ( ) . length > SEMANTIC_TOKEN_CONTENT_LENGTH_LIMIT ) {
808
+ return [ ] ;
809
809
}
810
810
811
811
const fileFsPath = getFileFsPath ( doc . uri ) ;
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ export interface ProjectService {
64
64
onCodeAction ( params : CodeActionParams ) : Promise < CodeAction [ ] > ;
65
65
onCodeActionResolve ( action : CodeAction ) : Promise < CodeAction > ;
66
66
onWillRenameFile ( fileRename : FileRename ) : Promise < TextDocumentEdit [ ] > ;
67
- onSemanticTokens ( params : SemanticTokensParams | SemanticTokensRangeParams ) : Promise < SemanticTokens | null > ;
67
+ onSemanticTokens ( params : SemanticTokensParams | SemanticTokensRangeParams ) : Promise < SemanticTokens > ;
68
68
doValidate ( doc : TextDocument , cancellationToken ?: VCancellationToken ) : Promise < Diagnostic [ ] | null > ;
69
69
dispose ( ) : Promise < void > ;
70
70
}
@@ -356,10 +356,7 @@ export async function createProjectService(
356
356
357
357
for ( const mode of modes ) {
358
358
const tokenData = mode . mode . getSemanticTokens ?.( doc , range ) ;
359
- // all or nothing
360
- if ( tokenData === null ) {
361
- return null ;
362
- }
359
+
363
360
data . push ( ...( tokenData ?? [ ] ) ) ;
364
361
}
365
362
Original file line number Diff line number Diff line change @@ -391,8 +391,8 @@ export class VLS {
391
391
this . lspConnection . onCodeAction ( this . onCodeAction . bind ( this ) ) ;
392
392
this . lspConnection . onCodeActionResolve ( this . onCodeActionResolve . bind ( this ) ) ;
393
393
this . lspConnection . workspace . onWillRenameFiles ( this . onWillRenameFiles . bind ( this ) ) ;
394
- this . lspConnection . onRequest ( SemanticTokensRequest . type , this . onSemanticToken . bind ( this ) ) ;
395
- this . lspConnection . onRequest ( SemanticTokensRangeRequest . type , this . onSemanticToken . bind ( this ) ) ;
394
+ this . lspConnection . languages . semanticTokens . on ( this . onSemanticToken . bind ( this ) ) ;
395
+ this . lspConnection . languages . semanticTokens . onRange ( this . onSemanticToken . bind ( this ) ) ;
396
396
397
397
this . lspConnection . onDocumentColor ( this . onDocumentColors . bind ( this ) ) ;
398
398
this . lspConnection . onColorPresentation ( this . onColorPresentations . bind ( this ) ) ;
@@ -629,10 +629,10 @@ export class VLS {
629
629
} ;
630
630
}
631
631
632
- async onSemanticToken ( params : SemanticTokensParams | SemanticTokensRangeParams ) : Promise < SemanticTokens | null > {
632
+ async onSemanticToken ( params : SemanticTokensParams | SemanticTokensRangeParams ) : Promise < SemanticTokens > {
633
633
const project = await this . getProjectService ( params . textDocument . uri ) ;
634
634
635
- return project ?. onSemanticTokens ( params ) ?? null ;
635
+ return project ?. onSemanticTokens ( params ) ?? { data : [ ] as number [ ] } ;
636
636
}
637
637
638
638
private triggerValidation ( textDocument : TextDocument ) : void {
You can’t perform that action at this time.
0 commit comments