Skip to content

Commit 9c1f396

Browse files
committed
Reafactor after comments
1 parent 2a8766c commit 9c1f396

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

src/harness/fourslashImpl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ namespace FourSlash {
25632563
const identifier = this.classificationToIdentifier(a.classificationType as number);
25642564
const text = this.activeFile.content.slice(a.textSpan.start, a.textSpan.start + a.textSpan.length);
25652565
replacement.push(` c2.semanticToken("${identifier}", "${text}"), `);
2566-
});
2566+
};
25672567
replacement.push(");");
25682568

25692569
throw new Error("You need to change the source code of fourslash test to use replaceWithSemanticClassifications");

src/services/classifier2020.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ namespace ts.classifier.modern {
33

44
/** @internal */
55
export const enum TokenEncodingConsts {
6-
76
typeOffset = 8,
87
modifierMask = (1 << typeOffset) - 1
98
}
109

1110
/** @internal */
1211
export const enum TokenType {
13-
class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member, _
12+
class, enum, interface, namespace, typeParameter, type, parameter, variable, enumMember, property, function, member
1413
}
1514

1615
/** @internal */
1716
export const enum TokenModifier {
18-
declaration, static, async, readonly, defaultLibrary, local, _
17+
declaration, static, async, readonly, defaultLibrary, local
1918
}
2019

2120
/** This is mainly used internally for testing */
@@ -26,10 +25,10 @@ namespace ts.classifier.modern {
2625
const dense = classifications.spans;
2726
const result: ClassifiedSpan[] = [];
2827
for (let i = 0; i < dense.length; i += 3) {
29-
result.push({
30-
textSpan: createTextSpan(dense[i], dense[i + 1]),
31-
classificationType: dense[i + 2]
32-
});
28+
result.push({
29+
textSpan: createTextSpan(dense[i], dense[i + 1]),
30+
classificationType: dense[i + 2]
31+
});
3332
}
3433

3534
return result;
@@ -46,7 +45,7 @@ namespace ts.classifier.modern {
4645
const resultTokens: number[] = [];
4746

4847
const collector = (node: Node, typeIdx: number, modifierSet: number) => {
49-
resultTokens.push(node.getStart(), node.getWidth(), ((typeIdx + 1) << TokenEncodingConsts.typeOffset) + modifierSet);
48+
resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << TokenEncodingConsts.typeOffset) + modifierSet);
5049
};
5150

5251
if (program && sourceFile) {

src/services/services.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1805,11 +1805,11 @@ namespace ts {
18051805
synchronizeHostData();
18061806

18071807
const responseFormat = format || SemanticClassificationFormat.Original;
1808-
if (responseFormat === SemanticClassificationFormat.Original) {
1809-
return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
1808+
if (responseFormat === SemanticClassificationFormat.TwentyTwenty) {
1809+
return classifier.modern.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span);
18101810
}
18111811
else {
1812-
return classifier.modern.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span);
1812+
return ts.getSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span);
18131813
}
18141814
}
18151815

0 commit comments

Comments
 (0)