Skip to content

Commit 25aed11

Browse files
Unify more classification code.
1 parent 089fd4d commit 25aed11

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

src/services/services.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,8 @@ module ts {
15051505
public static interfaceName = "interface name";
15061506
public static moduleName = "module name";
15071507
public static typeParameterName = "type parameter name";
1508-
public static typeAlias = "type alias name";
1508+
public static typeAliasName = "type alias name";
1509+
public static parameterName = "type alias name";
15091510
}
15101511

15111512
export const enum ClassificationType {
@@ -1524,7 +1525,7 @@ module ts {
15241525
interfaceName = 13,
15251526
moduleName = 14,
15261527
typeParameterName = 15,
1527-
typeAlias = 16,
1528+
typeAliasName = 16,
15281529
parameterName = 17
15291530
}
15301531

@@ -5873,7 +5874,7 @@ module ts {
58735874
return ClassificationType.enumName;
58745875
}
58755876
else if (flags & SymbolFlags.TypeAlias) {
5876-
return ClassificationType.typeAlias;
5877+
return ClassificationType.typeAliasName;
58775878
}
58785879
else if (meaningAtPosition & SemanticMeaning.Type) {
58795880
if (flags & SymbolFlags.Interface) {
@@ -5939,7 +5940,8 @@ module ts {
59395940
case ClassificationType.interfaceName: return ClassificationTypeNames.interfaceName;
59405941
case ClassificationType.moduleName: return ClassificationTypeNames.moduleName;
59415942
case ClassificationType.typeParameterName: return ClassificationTypeNames.typeParameterName;
5942-
case ClassificationType.typeAlias: return ClassificationTypeNames.typeAlias;
5943+
case ClassificationType.typeAliasName: return ClassificationTypeNames.typeAliasName;
5944+
case ClassificationType.parameterName: return ClassificationTypeNames.parameterName;
59435945
}
59445946
}
59455947

@@ -6144,6 +6146,12 @@ module ts {
61446146
return ClassificationType.moduleName;
61456147
}
61466148
return;
6149+
case SyntaxKind.Parameter:
6150+
if ((<ParameterDeclaration>token.parent).name === token) {
6151+
return ClassificationType.parameterName;
6152+
}
6153+
return;
6154+
61476155
}
61486156
}
61496157

@@ -6666,7 +6674,7 @@ module ts {
66666674
case ClassificationType.interfaceName:
66676675
case ClassificationType.moduleName:
66686676
case ClassificationType.typeParameterName:
6669-
case ClassificationType.typeAlias:
6677+
case ClassificationType.typeAliasName:
66706678
case ClassificationType.text:
66716679
case ClassificationType.parameterName:
66726680
default:

tests/cases/fourslash/fourslash.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,12 @@ module FourSlashInterface {
651651
return getClassification("typeParameterName", text, position);
652652
}
653653

654-
export function typeAlias(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
655-
return getClassification("typeAlias", text, position);
654+
export function parameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
655+
return getClassification("parameterName", text, position);
656+
}
657+
658+
export function typeAliasName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
659+
return getClassification("typeAliasName", text, position);
656660
}
657661

658662
function getClassification(type: string, text: string, position?: number) {

tests/cases/fourslash/semanticClassificatonTypeAlias.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
var c = classification;
99
verify.semanticClassificationsAre(
10-
c.typeAlias("Alias", test.marker("0").position),
11-
c.typeAlias("Alias", test.marker("1").position),
12-
c.typeAlias("Alias", test.marker("2").position),
13-
c.typeAlias("Alias", test.marker("3").position),
14-
c.typeAlias("Alias", test.marker("4").position)
10+
c.typeAliasName("Alias", test.marker("0").position),
11+
c.typeAliasName("Alias", test.marker("1").position),
12+
c.typeAliasName("Alias", test.marker("2").position),
13+
c.typeAliasName("Alias", test.marker("3").position),
14+
c.typeAliasName("Alias", test.marker("4").position)
1515
);

tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var firstCommentText =
1919
var c = classification;
2020
verify.syntacticClassificationsAre(
2121
c.comment(firstCommentText),
22-
c.keyword("function"), c.text("myFunction"), c.punctuation("("), c.comment("/* x */"), c.text("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"),
22+
c.keyword("function"), c.text("myFunction"), c.punctuation("("), c.comment("/* x */"), c.parameterName("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"),
2323
c.keyword("var"), c.text("y"), c.operator("="), c.text("x"), c.operator("?"), c.text("x"), c.operator("++"), c.operator(":"), c.operator("++"), c.text("x"), c.punctuation(";"),
2424
c.punctuation("}"),
2525
c.comment("// end of file"));

0 commit comments

Comments
 (0)