diff --git a/src/services/services.ts b/src/services/services.ts index 3df83af1028..4b1a16a89b6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2917,11 +2917,28 @@ module ts { } if (symbolFlags & SymbolFlags.Import) { addNewLineIfDisplayPartsExist(); - displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); - displayParts.push(textPart("alias")); - displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + displayParts.push(keywordPart(SyntaxKind.ImportKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); + displayParts.push(spacePart()); + displayParts.push(punctuationPart(SyntaxKind.EqualsToken)); + displayParts.push(spacePart()); + ts.forEach(symbol.declarations, declaration => { + if (declaration.kind === SyntaxKind.ImportDeclaration) { + var importDeclaration = declaration; + if (importDeclaration.externalModuleName) { + displayParts.push(keywordPart(SyntaxKind.RequireKeyword)); + displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); + displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral)); + displayParts.push(punctuationPart(SyntaxKind.CloseParenToken)); + } + else { + var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } + return true; + } + }); } if (!hasAddedSymbolInfo) { if (symbolKind !== ScriptElementKind.unknown) { @@ -3028,7 +3045,7 @@ module ts { case SyntaxKind.QualifiedName: case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: - // For the identifiers/this/usper etc get the type at position + // For the identifiers/this/super etc get the type at position var type = typeInfoResolver.getTypeOfNode(node); if (type) { return { diff --git a/tests/cases/fourslash/commentsExternalModules.ts b/tests/cases/fourslash/commentsExternalModules.ts index 0eed08ca01e..c0e27149202 100644 --- a/tests/cases/fourslash/commentsExternalModules.ts +++ b/tests/cases/fourslash/commentsExternalModules.ts @@ -69,10 +69,10 @@ verify.memberListContains("i", "(var) m1.m2.i: m1.m2.c", "i"); goTo.file("commentsExternalModules_file1.ts"); goTo.marker('9'); -verify.quickInfoIs('(alias) extMod', "This is on import declaration"); +verify.quickInfoIs('import extMod = require("commentsExternalModules_file0")', "This is on import declaration"); goTo.marker('10'); -verify.completionListContains("extMod", "(alias) extMod", "This is on import declaration"); +verify.completionListContains("extMod", 'import extMod = require("commentsExternalModules_file0")', "This is on import declaration"); goTo.marker('11'); verify.memberListContains("m1", "module extMod.m1"); diff --git a/tests/cases/fourslash/commentsImportDeclaration.ts b/tests/cases/fourslash/commentsImportDeclaration.ts index 192cb2763ca..f115f3607b7 100644 --- a/tests/cases/fourslash/commentsImportDeclaration.ts +++ b/tests/cases/fourslash/commentsImportDeclaration.ts @@ -28,7 +28,7 @@ goTo.marker('2'); verify.quickInfoIs("module m1", "ModuleComment"); goTo.marker('3'); -verify.quickInfoIs("(alias) extMod", "Import declaration"); +verify.quickInfoIs('import extMod = require("commentsImportDeclaration_file0")', "Import declaration"); goTo.marker('6'); verify.memberListContains("m1", "module extMod.m1"); diff --git a/tests/cases/fourslash/completionListOnAliases.ts b/tests/cases/fourslash/completionListOnAliases.ts index 68c25d3608e..3d9026c3036 100644 --- a/tests/cases/fourslash/completionListOnAliases.ts +++ b/tests/cases/fourslash/completionListOnAliases.ts @@ -9,7 +9,7 @@ ////} goTo.marker("1"); -verify.memberListContains("x", "(alias) x", undefined); +verify.memberListContains("x", "import x = M", undefined); goTo.marker("2"); verify.memberListContains("value"); diff --git a/tests/cases/fourslash/exportEqualTypes.ts b/tests/cases/fourslash/exportEqualTypes.ts index 47a266f7f39..8cfe931d87b 100644 --- a/tests/cases/fourslash/exportEqualTypes.ts +++ b/tests/cases/fourslash/exportEqualTypes.ts @@ -15,7 +15,7 @@ ////var /*3*/r2 = t./*4*/foo; // t should have 'foo' in dropdown list and be of type 'string' goTo.marker('1'); -verify.quickInfoIs('(alias) test'); +verify.quickInfoIs("import test = require('exportEqualTypes_file0')"); goTo.marker('2'); verify.quickInfoIs('(var) r1: Date'); goTo.marker('3'); diff --git a/tests/cases/fourslash/externalModuleWithExportAssignment.ts b/tests/cases/fourslash/externalModuleWithExportAssignment.ts index 952640f2c6c..1de1e55579b 100644 --- a/tests/cases/fourslash/externalModuleWithExportAssignment.ts +++ b/tests/cases/fourslash/externalModuleWithExportAssignment.ts @@ -30,7 +30,7 @@ goTo.file("externalModuleWithExportAssignment_file1.ts"); goTo.marker('1'); -verify.quickInfoIs("(alias) a1"); +verify.quickInfoIs('import a1 = require("externalModuleWithExportAssignment_file0")'); goTo.marker('2'); verify.quickInfoIs("(var) a: {\n (): a1.connectExport;\n test1: a1.connectModule;\n test2(): a1.connectModule;\n}", undefined); diff --git a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts index be5376d5de5..3198b6e9243 100644 --- a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts +++ b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts @@ -19,7 +19,7 @@ edit.insert(''); goTo.marker('1'); -verify.quickInfoIs('(alias) Foo'); +verify.quickInfoIs("import Foo = require('mergedDeclarationsWithExportAssignment1_file0')"); goTo.marker('2'); verify.completionListContains('Foo'); diff --git a/tests/cases/fourslash/quickInfoOnInternalAliases.ts b/tests/cases/fourslash/quickInfoOnInternalAliases.ts index 8c269ac6565..d144594197a 100644 --- a/tests/cases/fourslash/quickInfoOnInternalAliases.ts +++ b/tests/cases/fourslash/quickInfoOnInternalAliases.ts @@ -11,12 +11,27 @@ ////} /////**This is on import declaration*/ ////import /*2*/internalAlias = m1.m2./*3*/c; +////var /*4*/newVar = new /*5*/internalAlias(); +////var /*6*/anotherAliasVar = /*7*/internalAlias; + goTo.marker('1'); verify.quickInfoIs("class m1.m2.c", "class comment;"); goTo.marker('2'); -verify.quickInfoIs('(alias) internalAlias', "This is on import declaration"); +verify.quickInfoIs('import internalAlias = m1.m2.c', "This is on import declaration"); goTo.marker('3'); -verify.quickInfoIs("class m1.m2.c", "class comment;"); \ No newline at end of file +verify.quickInfoIs("class m1.m2.c", "class comment;"); + +goTo.marker('4'); +verify.quickInfoIs("(var) newVar: internalAlias", ""); + +goTo.marker('5'); +verify.quickInfoIs("import internalAlias = m1.m2.c", "This is on import declaration"); + +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 diff --git a/tests/cases/fourslash/selfReferencedExternalModule.ts b/tests/cases/fourslash/selfReferencedExternalModule.ts index ec312ccb1e5..f5e955839c7 100644 --- a/tests/cases/fourslash/selfReferencedExternalModule.ts +++ b/tests/cases/fourslash/selfReferencedExternalModule.ts @@ -5,5 +5,5 @@ ////A./**/I goTo.marker(); -verify.completionListContains("A", "(alias) A"); +verify.completionListContains("A", "import A = require('app')"); verify.completionListContains("I", "(var) I: number"); \ No newline at end of file