mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Unify more classification code.
This commit is contained in:
parent
5ad7a593d4
commit
c0c2c4f9a3
@ -1505,7 +1505,8 @@ module ts {
|
||||
public static interfaceName = "interface name";
|
||||
public static moduleName = "module name";
|
||||
public static typeParameterName = "type parameter name";
|
||||
public static typeAlias = "type alias name";
|
||||
public static typeAliasName = "type alias name";
|
||||
public static parameterName = "type alias name";
|
||||
}
|
||||
|
||||
export const enum ClassificationType {
|
||||
@ -1524,7 +1525,7 @@ module ts {
|
||||
interfaceName = 13,
|
||||
moduleName = 14,
|
||||
typeParameterName = 15,
|
||||
typeAlias = 16,
|
||||
typeAliasName = 16,
|
||||
parameterName = 17
|
||||
}
|
||||
|
||||
@ -5876,7 +5877,7 @@ module ts {
|
||||
return ClassificationType.enumName;
|
||||
}
|
||||
else if (flags & SymbolFlags.TypeAlias) {
|
||||
return ClassificationType.typeAlias;
|
||||
return ClassificationType.typeAliasName;
|
||||
}
|
||||
else if (meaningAtPosition & SemanticMeaning.Type) {
|
||||
if (flags & SymbolFlags.Interface) {
|
||||
@ -5942,7 +5943,8 @@ module ts {
|
||||
case ClassificationType.interfaceName: return ClassificationTypeNames.interfaceName;
|
||||
case ClassificationType.moduleName: return ClassificationTypeNames.moduleName;
|
||||
case ClassificationType.typeParameterName: return ClassificationTypeNames.typeParameterName;
|
||||
case ClassificationType.typeAlias: return ClassificationTypeNames.typeAlias;
|
||||
case ClassificationType.typeAliasName: return ClassificationTypeNames.typeAliasName;
|
||||
case ClassificationType.parameterName: return ClassificationTypeNames.parameterName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6147,6 +6149,12 @@ module ts {
|
||||
return ClassificationType.moduleName;
|
||||
}
|
||||
return;
|
||||
case SyntaxKind.Parameter:
|
||||
if ((<ParameterDeclaration>token.parent).name === token) {
|
||||
return ClassificationType.parameterName;
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -6669,7 +6677,7 @@ module ts {
|
||||
case ClassificationType.interfaceName:
|
||||
case ClassificationType.moduleName:
|
||||
case ClassificationType.typeParameterName:
|
||||
case ClassificationType.typeAlias:
|
||||
case ClassificationType.typeAliasName:
|
||||
case ClassificationType.text:
|
||||
case ClassificationType.parameterName:
|
||||
default:
|
||||
|
||||
@ -651,8 +651,12 @@ module FourSlashInterface {
|
||||
return getClassification("typeParameterName", text, position);
|
||||
}
|
||||
|
||||
export function typeAlias(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
|
||||
return getClassification("typeAlias", text, position);
|
||||
export function parameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
|
||||
return getClassification("parameterName", text, position);
|
||||
}
|
||||
|
||||
export function typeAliasName(text: string, position?: number): { classificationType: string; text: string; textSpan?: TextSpan } {
|
||||
return getClassification("typeAliasName", text, position);
|
||||
}
|
||||
|
||||
function getClassification(type: string, text: string, position?: number) {
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
|
||||
var c = classification;
|
||||
verify.semanticClassificationsAre(
|
||||
c.typeAlias("Alias", test.marker("0").position),
|
||||
c.typeAlias("Alias", test.marker("1").position),
|
||||
c.typeAlias("Alias", test.marker("2").position),
|
||||
c.typeAlias("Alias", test.marker("3").position),
|
||||
c.typeAlias("Alias", test.marker("4").position)
|
||||
c.typeAliasName("Alias", test.marker("0").position),
|
||||
c.typeAliasName("Alias", test.marker("1").position),
|
||||
c.typeAliasName("Alias", test.marker("2").position),
|
||||
c.typeAliasName("Alias", test.marker("3").position),
|
||||
c.typeAliasName("Alias", test.marker("4").position)
|
||||
);
|
||||
@ -19,7 +19,7 @@ var firstCommentText =
|
||||
var c = classification;
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment(firstCommentText),
|
||||
c.keyword("function"), c.text("myFunction"), c.punctuation("("), c.comment("/* x */"), c.text("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"),
|
||||
c.keyword("function"), c.text("myFunction"), c.punctuation("("), c.comment("/* x */"), c.parameterName("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"),
|
||||
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(";"),
|
||||
c.punctuation("}"),
|
||||
c.comment("// end of file"));
|
||||
Loading…
x
Reference in New Issue
Block a user