mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Support semantic highlights for JS files (#43992)
* Switches from never allowing semantic highlight on JS to only doing it if we have a valid source file * Adds a way to test and validate that an arbitrary JS file gets semantic classification results * Revert to just dropping the if statement
This commit is contained in:
@@ -1882,17 +1882,8 @@ namespace ts {
|
||||
return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken);
|
||||
}
|
||||
|
||||
function isTsOrTsxFile(fileName: string): boolean {
|
||||
const kind = getScriptKind(fileName, host);
|
||||
return kind === ScriptKind.TS || kind === ScriptKind.TSX;
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): ClassifiedSpan[] | ClassifiedSpan2020[] {
|
||||
if (!isTsOrTsxFile(fileName)) {
|
||||
// do not run semantic classification on non-ts-or-tsx files
|
||||
return [];
|
||||
}
|
||||
synchronizeHostData();
|
||||
|
||||
const responseFormat = format || SemanticClassificationFormat.Original;
|
||||
@@ -1905,10 +1896,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getEncodedSemanticClassifications(fileName: string, span: TextSpan, format?: SemanticClassificationFormat): Classifications {
|
||||
if (!isTsOrTsxFile(fileName)) {
|
||||
// do not run semantic classification on non-ts-or-tsx files
|
||||
return { spans: [], endOfLineState: EndOfLineState.None };
|
||||
}
|
||||
synchronizeHostData();
|
||||
|
||||
const responseFormat = format || SemanticClassificationFormat.Original;
|
||||
|
||||
Reference in New Issue
Block a user