diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index 9cc6641526819..b3bab59ad1c82 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -2564,7 +2564,7 @@ namespace FourSlash { const identifier = this.classificationToIdentifier(a.classificationType as number); const text = this.activeFile.content.slice(a.textSpan.start, a.textSpan.start + a.textSpan.length); replacement.push(` c2.semanticToken("${identifier}", "${text}"), `); - }); + }; replacement.push(");"); throw new Error("You need to change the source code of fourslash test to use replaceWithSemanticClassifications"); diff --git a/src/services/classifier2020.ts b/src/services/classifier2020.ts index 2df3cf3e0a243..adbac20b3e7e6 100644 --- a/src/services/classifier2020.ts +++ b/src/services/classifier2020.ts @@ -3,19 +3,18 @@ namespace ts.classifier.modern { /** @internal */ export const enum TokenEncodingConsts { - typeOffset = 8, modifierMask = (1 << typeOffset) - 1 } /** @internal */ export const enum TokenType { - class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member, _ + class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member } /** @internal */ export const enum TokenModifier { - declaration, static, async, readonly, defaultLibrary, local, _ + declaration, static, async, readonly, defaultLibrary, local } /** This is mainly used internally for testing */ @@ -26,10 +25,10 @@ namespace ts.classifier.modern { const dense = classifications.spans; const result: ClassifiedSpan[] = []; for (let i = 0; i < dense.length; i += 3) { - result.push({ - textSpan: createTextSpan(dense[i], dense[i + 1]), - classificationType: dense[i + 2] - }); + result.push({ + textSpan: createTextSpan(dense[i], dense[i + 1]), + classificationType: dense[i + 2] + }); } return result; @@ -46,7 +45,7 @@ namespace ts.classifier.modern { const resultTokens: number[] = []; const collector = (node: Node, typeIdx: number, modifierSet: number) => { - resultTokens.push(node.getStart(), node.getWidth(), ((typeIdx + 1) << TokenEncodingConsts.typeOffset) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << TokenEncodingConsts.typeOffset) + modifierSet); }; if (program && sourceFile) { diff --git a/src/services/services.ts b/src/services/services.ts index f279a8be80490..fafe99387ec47 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1802,11 +1802,11 @@ namespace ts { synchronizeHostData(); const responseFormat = format || SemanticClassificationFormat.Original; - if (responseFormat === SemanticClassificationFormat.Original) { - return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); + if (responseFormat === SemanticClassificationFormat.TwentyTwenty) { + return classifier.modern.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { - return classifier.modern.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); + return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } }