From 3715af1a5abddcf62e56f66a429a5ee6cc62fd53 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 10 Oct 2014 15:52:34 -0700 Subject: [PATCH] Show call and construct signatures when using aliases --- src/services/services.ts | 14 +++++++++- .../fourslash/quickInfoOnInternalAliases.ts | 28 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 4b1a16a89b6..a3e6d7a5445 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2749,7 +2749,7 @@ module ts { var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags); var hasAddedSymbolInfo: boolean; // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Signature || symbolFlags & SymbolFlags.Class) { + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Import) { // If it is accessor they are allowed only if location is at name of the accessor if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; @@ -2790,6 +2790,18 @@ module ts { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } + else if (symbolFlags & SymbolFlags.Import) { + symbolKind = ScriptElementKind.alias; + displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); + displayParts.push(textPart(symbolKind)); + displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + displayParts.push(spacePart()); + if (useConstructSignatures) { + displayParts.push(keywordPart(SyntaxKind.NewKeyword)); + displayParts.push(spacePart()); + } + addFullSymbolName(symbol); + } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } diff --git a/tests/cases/fourslash/quickInfoOnInternalAliases.ts b/tests/cases/fourslash/quickInfoOnInternalAliases.ts index d144594197a..b1c562df494 100644 --- a/tests/cases/fourslash/quickInfoOnInternalAliases.ts +++ b/tests/cases/fourslash/quickInfoOnInternalAliases.ts @@ -8,12 +8,16 @@ //// export class /*1*/c { //// }; //// } +//// export function foo() { +//// } ////} /////**This is on import declaration*/ ////import /*2*/internalAlias = m1.m2./*3*/c; ////var /*4*/newVar = new /*5*/internalAlias(); ////var /*6*/anotherAliasVar = /*7*/internalAlias; - +////import /*8*/internalFoo = m1./*9*/foo; +////var /*10*/callVar = /*11*/internalFoo(); +////var /*12*/anotherAliasFoo = /*13*/internalFoo; goTo.marker('1'); verify.quickInfoIs("class m1.m2.c", "class comment;"); @@ -28,10 +32,28 @@ goTo.marker('4'); verify.quickInfoIs("(var) newVar: internalAlias", ""); goTo.marker('5'); -verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration"); +verify.quickInfoIs("(alias) new internalAlias(): internalAlias\nimport internalAlias = m1.m2.c", ""); goTo.marker('6'); verify.quickInfoIs("(var) anotherAliasVar: typeof internalAlias", ""); goTo.marker('7'); -verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration"); \ No newline at end of file +verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration"); + +goTo.marker('8'); +verify.quickInfoIs('import internalFoo = m1.foo', ""); + +goTo.marker('9'); +verify.quickInfoIs("(function) m1.foo(): void", ""); + +goTo.marker('10'); +verify.quickInfoIs("(var) callVar: void", ""); + +goTo.marker('11'); +verify.quickInfoIs("(alias) internalFoo(): void\nimport internalFoo = m1.foo", ""); + +goTo.marker('12'); +verify.quickInfoIs("(var) anotherAliasFoo: () => void", ""); + +goTo.marker('13'); +verify.quickInfoIs("import internalFoo = m1.foo", ""); \ No newline at end of file