Skip to content

Commit 417cd94

Browse files
committed
Alias name formatting
1 parent 99f67d6 commit 417cd94

File tree

4 files changed

+116
-106
lines changed

4 files changed

+116
-106
lines changed

src/services/services.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,14 @@ module ts {
28332833
}
28342834
}
28352835
}
2836+
if (symbolFlags & SymbolFlags.Import) {
2837+
addNewLineIfDisplayPartsExist();
2838+
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
2839+
displayParts.push(textPart("alias"));
2840+
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
2841+
displayParts.push(spacePart());
2842+
displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile));
2843+
}
28362844
else if (!hasAddedSymbolInfo && symbolKind !== ScriptElementKind.unknown) {
28372845
if (type) {
28382846
addPrefixForAnyFunctionOrVar(symbol, symbolKind);
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @Filename: commentsExternalModules_file0.ts
4+
/////** Module comment*/
5+
////export module m/*1*/1 {
6+
//// /** b's comment*/
7+
//// export var b: number;
8+
//// /** foo's comment*/
9+
//// function foo() {
10+
//// return /*2*/b;
11+
//// }
12+
//// /** m2 comments*/
13+
//// export module m2 {
14+
//// /** class comment;*/
15+
//// export class c {
16+
//// };
17+
//// /** i*/
18+
//// export var i = new c();
19+
//// }
20+
//// /** exported function*/
21+
//// export function fooExport() {
22+
//// return f/*3q*/oo(/*3*/);
23+
//// }
24+
////}
25+
/////*4*/m1./*5*/fooEx/*6q*/port(/*6*/);
26+
////var my/*7*/var = new m1.m2./*8*/c();
27+
28+
// @Filename: commentsExternalModules_file1.ts
29+
/////**This is on import declaration*/
30+
////import ex/*9*/tMod = require("commentsExternalModules_file0");
31+
/////*10*/extMod./*11*/m1./*12*/fooExp/*13q*/ort(/*13*/);
32+
////var new/*14*/Var = new extMod.m1.m2./*15*/c();
33+
34+
// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed
35+
edit.insert('');
36+
37+
goTo.file("commentsExternalModules_file0.ts");
38+
goTo.marker('1');
39+
verify.quickInfoIs("module m1", "Module comment");
40+
41+
goTo.marker('2');
42+
verify.completionListContains("b", "(var) m1.b: number", "b's comment");
43+
verify.completionListContains("foo", "(function) foo(): number", "foo's comment");
44+
45+
goTo.marker('3');
46+
verify.currentSignatureHelpDocCommentIs("foo's comment");
47+
goTo.marker('3q');
48+
verify.quickInfoIs("(function) foo(): number", "foo's comment");
49+
50+
goTo.marker('4');
51+
verify.completionListContains("m1", "module m1", "Module comment");
52+
53+
goTo.marker('5');
54+
verify.memberListContains("b", "(var) m1.b: number", "b's comment");
55+
verify.memberListContains("fooExport", "(function) m1.fooExport(): number", "exported function");
56+
verify.memberListContains("m2", "module m1.m2");
57+
58+
goTo.marker('6');
59+
verify.currentSignatureHelpDocCommentIs("exported function");
60+
goTo.marker('6q');
61+
verify.quickInfoIs("(function) m1.fooExport(): number", "exported function");
62+
63+
goTo.marker('7');
64+
verify.quickInfoIs("(var) myvar: m1.m2.c", "");
65+
66+
goTo.marker('8');
67+
verify.memberListContains("c", "class m1.m2.c", "class comment;");
68+
verify.memberListContains("i", "(var) m1.m2.i: m1.m2.c", "i");
69+
70+
goTo.file("commentsExternalModules_file1.ts");
71+
goTo.marker('9');
72+
verify.quickInfoIs('(alias) extMod', "This is on import declaration");
73+
74+
goTo.marker('10');
75+
// TODO: extMod should exist in the completion list
76+
//verify.completionListContains("extMod", "(alias) extMod", "This is on import declaration");
77+
verify.not.completionListContains("extMod", "(alias) extMod", "This is on import declaration");
78+
79+
goTo.marker('11');
80+
verify.memberListContains("m1", "module extMod.m1");
81+
82+
goTo.marker('12');
83+
verify.memberListContains("b", "(var) extMod.m1.b: number", "b's comment");
84+
verify.memberListContains("fooExport", "(function) extMod.m1.fooExport(): number", "exported function");
85+
verify.memberListContains("m2", "module extMod.m1.m2");
86+
87+
goTo.marker('13');
88+
verify.currentSignatureHelpDocCommentIs("exported function");
89+
goTo.marker('13q');
90+
verify.quickInfoIs("(function) extMod.m1.fooExport(): number", "exported function");
91+
92+
goTo.marker('14');
93+
verify.quickInfoIs("(var) newVar: extMod.m1.m2.c", "");
94+
95+
goTo.marker('15');
96+
verify.memberListContains("c", "class extMod.m1.m2.c", "class comment;");
97+
verify.memberListContains("i", "(var) extMod.m1.m2.i: extMod.m1.m2.c", "i");

tests/cases/fourslash_old/commentsImportDeclaration.ts renamed to tests/cases/fourslash/commentsImportDeclaration.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,32 @@
2020
// @Filename: commentsImportDeclaration_file1.ts
2121
///////<reference path='commentsImportDeclaration_file0.ts'/>
2222
/////** Import declaration*/
23-
////import extMod/*3*/ = require("commentsImportDeclaration_file0/*4*/");
23+
////import /*3*/extMod = require("commentsImportDeclaration_file0/*4*/");
2424
////extMod./*6*/m1./*7*/fooEx/*8q*/port(/*8*/);
2525
////var new/*9*/Var = new extMod.m1.m2./*10*/c();
2626

2727
goTo.marker('2');
28-
verify.quickInfoIs("m1", "ModuleComment", "m1", "module");
28+
verify.quickInfoIs("module m1", "ModuleComment");
2929

3030
goTo.marker('3');
31-
verify.quickInfoIs("extMod", "Import declaration", "extMod", "module");
31+
verify.quickInfoIs("(alias) extMod", "Import declaration");
3232

3333
goTo.marker('6');
34-
verify.memberListContains("m1", "extMod.m1");
34+
verify.memberListContains("m1", "module extMod.m1");
3535

3636
goTo.marker('7');
37-
verify.memberListContains("b", "number", "b's comment", "extMod.m1.b", "var");
38-
verify.memberListContains("fooExport", "(): number", "exported function", "extMod.m1.fooExport", "function");
39-
verify.memberListContains("m2", "extMod.m1.m2");
37+
verify.memberListContains("b", "(var) extMod.m1.b: number", "b's comment");
38+
verify.memberListContains("fooExport", "(function) extMod.m1.fooExport(): number", "exported function");
39+
verify.memberListContains("m2", "module extMod.m1.m2");
4040

4141
goTo.marker('8');
4242
verify.currentSignatureHelpDocCommentIs("exported function");
4343
goTo.marker('8q');
44-
verify.quickInfoIs("(): number", "exported function", "extMod.m1.fooExport", "function");
44+
verify.quickInfoIs("(function) extMod.m1.fooExport(): number", "exported function");
4545

4646
goTo.marker('9');
47-
verify.quickInfoIs("extMod.m1.m2.c", "", "newVar", "var");
47+
verify.quickInfoIs("(var) newVar: extMod.m1.m2.c", "");
4848

4949
goTo.marker('10');
50-
verify.memberListContains("c", undefined, "class comment;", "extMod.m1.m2.c", "class");
51-
verify.memberListContains("i", "extMod.m1.m2.c", "i", "extMod.m1.m2.i", "var");
50+
verify.memberListContains("c", "class extMod.m1.m2.c", "class comment;");
51+
verify.memberListContains("i", "(var) extMod.m1.m2.i: extMod.m1.m2.c", "i");

tests/cases/fourslash_old/commentsExternalModules.ts

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)