File tree Expand file tree Collapse file tree
packages/language-service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,6 +110,9 @@ export interface NgLanguageService extends ts.LanguageService {
110110 ) : Promise < ApplyRefactoringResult | undefined > ;
111111
112112 hasCodeFixesForErrorCode ( errorCode : number ) : boolean ;
113+
114+ getTokenTypeFromClassification ( classification : number ) : number | undefined ;
115+ getTokenModifierFromClassification ( classification : number ) : number ;
113116}
114117
115118export function isNgLanguageService (
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ import {
4949} from './utils/ts_utils' ;
5050import { getTypeCheckInfoAtPosition , isTypeScriptFile , TypeCheckInfo } from './utils' ;
5151import { ActiveRefactoring , allRefactorings } from './refactorings/refactoring' ;
52- import { getClassificationsForTemplate } from './semantic_tokens' ;
52+ import { getClassificationsForTemplate , TokenEncodingConsts } from './semantic_tokens' ;
5353import { isExternalResource } from '@angular/compiler-cli/src/ngtsc/metadata' ;
5454
5555type LanguageServiceConfig = Omit < PluginConfig , 'angularOnly' > ;
@@ -363,6 +363,17 @@ export class LanguageService {
363363 }
364364 }
365365
366+ getTokenTypeFromClassification ( classification : number ) : number | undefined {
367+ if ( classification > TokenEncodingConsts . modifierMask ) {
368+ return ( classification >> TokenEncodingConsts . typeOffset ) - 1 ;
369+ }
370+ return undefined ;
371+ }
372+
373+ getTokenModifierFromClassification ( classification : number ) {
374+ return classification & TokenEncodingConsts . modifierMask ;
375+ }
376+
366377 getCompletionsAtPosition (
367378 fileName : string ,
368379 position : number ,
Original file line number Diff line number Diff line change @@ -149,6 +149,13 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
149149 }
150150 }
151151
152+ function getTokenTypeFromClassification ( classification : number ) : number | undefined {
153+ return ngLS . getTokenTypeFromClassification ( classification ) ;
154+ }
155+ function getTokenModifierFromClassification ( classification : number ) : number {
156+ return ngLS . getTokenModifierFromClassification ( classification ) ;
157+ }
158+
152159 function getCompletionsAtPosition (
153160 fileName : string ,
154161 position : number ,
@@ -371,6 +378,8 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
371378 findRenameLocations,
372379 getRenameInfo,
373380 getEncodedSemanticClassifications,
381+ getTokenTypeFromClassification,
382+ getTokenModifierFromClassification,
374383 getCompletionsAtPosition,
375384 getCompletionEntryDetails,
376385 getCompletionEntrySymbol,
You can’t perform that action at this time.
0 commit comments