From f30bb7ec35ded5da9a3bce065174ca53ea7e30e7 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 5 Dec 2014 17:32:36 -0800 Subject: [PATCH] add classification for type aliases --- src/services/services.ts | 4 ++++ tests/cases/fourslash/fourslash.ts | 4 ++++ .../fourslash/semanticClassificatonTypeAlias.ts | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 tests/cases/fourslash/semanticClassificatonTypeAlias.ts diff --git a/src/services/services.ts b/src/services/services.ts index f74410d007e..980b7ecda3d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1291,6 +1291,7 @@ module ts { public static interfaceName = "interface name"; public static moduleName = "module name"; public static typeParameterName = "type parameter name"; + public static typeAlias = "type alias name"; } enum MatchKind { @@ -4946,6 +4947,9 @@ module ts { else if (flags & SymbolFlags.Enum) { return ClassificationTypeNames.enumName; } + else if (flags & SymbolFlags.TypeAlias) { + return ClassificationTypeNames.typeAlias; + } else if (meaningAtPosition & SemanticMeaning.Type) { if (flags & SymbolFlags.Interface) { return ClassificationTypeNames.interfaceName; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 62da4c0d62d..85197dd3ccb 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -639,6 +639,10 @@ 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); + } + function getClassification(type: string, text: string, position?: number) { return { classificationType: type, diff --git a/tests/cases/fourslash/semanticClassificatonTypeAlias.ts b/tests/cases/fourslash/semanticClassificatonTypeAlias.ts new file mode 100644 index 00000000000..726588a2c9e --- /dev/null +++ b/tests/cases/fourslash/semanticClassificatonTypeAlias.ts @@ -0,0 +1,15 @@ +/// + +////type /*0*/Alias = number +////var x: /*1*/Alias; +////var y = {}; +////function f(x: /*3*/Alias): /*4*/Alias { return undefined; } + +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) + ); \ No newline at end of file