expose getEncodedSemanticClassifications from TypeScript language service

pull/4788/head
Michael Zhao 1 month ago
parent a4b088e410
commit 37ba67ead0

@ -547,6 +547,18 @@ export interface TypeScriptWorker {
* @returns `Promise<typescript.InlayHint[]>`
*/
provideInlayHints(fileName: string, start: number, end: number): Promise<ReadonlyArray<any>>;
/**
* Get encoded semantic classifications in the range of the file.
*
* The returned number array is encoded as triples of [start, length, ClassificationType, ...].
* @returns `Promise<typescript.Classifications | undefined>`
*/
getEncodedSemanticClassifications(
fileName: string,
start: number,
end: number
): Promise<{ spans: number[] } | undefined>;
}
// --- TypeScript configuration and defaults ---------

@ -473,6 +473,21 @@ export class TypeScriptWorker implements ts.LanguageServiceHost, ITypeScriptWork
return [];
}
}
async getEncodedSemanticClassifications(
fileName: string,
start: number,
end: number
): Promise<ts.Classifications | undefined> {
if (fileNameIsLib(fileName)) {
return undefined;
}
return this._languageService.getEncodedSemanticClassifications(
fileName,
{ start, length: end - start },
'2020' as ts.SemanticClassificationFormat
);
}
}
export interface ICreateData {

Loading…
Cancel
Save