Skip to content

Commit 99f67d6

Browse files
committed
Get the doc comments for dotted module declarations with docComments going to inner most module declaration
Enable module declaration comments and type name formatting tests
1 parent 3294c2b commit 99f67d6

File tree

3 files changed

+261
-251
lines changed

3 files changed

+261
-251
lines changed

src/services/services.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,16 @@ module ts {
284284
});
285285
}
286286

287+
// If this is left side of dotted module declaration, there is no doc comments associated with this node
288+
if (declaration.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>declaration).body.kind === SyntaxKind.ModuleDeclaration) {
289+
return;
290+
}
291+
292+
// If this is dotted module name, get the doc comments from the parent
293+
while (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.parent.kind === SyntaxKind.ModuleDeclaration) {
294+
declaration = declaration.parent;
295+
}
296+
287297
// Get the cleaned js doc comment text from the declaration
288298
ts.forEach(getJsDocCommentTextRange(
289299
declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent : declaration, sourceFileOfDeclaration), jsDocCommentTextRange => {
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////** Module comment*/
4+
////module m/*1*/1 {
5+
//// /** b's comment*/
6+
//// export var b: number;
7+
//// /** foo's comment*/
8+
//// function foo() {
9+
//// return /*2*/b;
10+
//// }
11+
//// /** m2 comments*/
12+
//// export module m2 {
13+
//// /** class comment;*/
14+
//// export class c {
15+
//// };
16+
//// /** i*/
17+
//// export var i = new c();
18+
//// }
19+
//// /** exported function*/
20+
//// export function fooExport() {
21+
//// return fo/*3q*/o(/*3*/);
22+
//// }
23+
////}
24+
/////*4*/m1./*5*/fooExport(/*6*/);
25+
////var my/*7*/var = new m1.m2./*8*/c();
26+
/////** module comment of m2.m3*/
27+
////module m2.m3 {
28+
//// /** Exported class comment*/
29+
//// export class c {
30+
//// }
31+
////}
32+
////new /*9*/m2./*10*/m3./*11*/c();
33+
/////** module comment of m3.m4.m5*/
34+
////module m3.m4.m5 {
35+
//// /** Exported class comment*/
36+
//// export class c {
37+
//// }
38+
////}
39+
////new /*12*/m3./*13*/m4./*14*/m5./*15*/c();
40+
/////** module comment of m4.m5.m6*/
41+
////module m4.m5.m6 {
42+
//// export module m7 {
43+
//// /** Exported class comment*/
44+
//// export class c {
45+
//// }
46+
//// }
47+
////}
48+
////new /*16*/m4./*17*/m5./*18*/m6./*19*/m7./*20*/c();
49+
/////** module comment of m5.m6.m7*/
50+
////module m5.m6.m7 {
51+
//// /** module m8 comment*/
52+
//// export module m8 {
53+
//// /** Exported class comment*/
54+
//// export class c {
55+
//// }
56+
//// }
57+
////}
58+
////new /*21*/m5./*22*/m6./*23*/m7./*24*/m8./*25*/c();
59+
////module m6.m7 {
60+
//// export module m8 {
61+
//// /** Exported class comment*/
62+
//// export class c {
63+
//// }
64+
//// }
65+
////}
66+
////new /*26*/m6./*27*/m7./*28*/m8./*29*/c();
67+
////module m7.m8 {
68+
//// /** module m9 comment*/
69+
//// export module m9 {
70+
//// /** Exported class comment*/
71+
//// export class c {
72+
//// }
73+
//// }
74+
////}
75+
////new /*30*/m7./*31*/m8./*32*/m9./*33*/c();
76+
////declare module "quotedM" {
77+
//// export class c {
78+
//// }
79+
//// export var b: /*34*/c;
80+
////}
81+
////module complexM {
82+
//// export module m1 {
83+
//// export class c {
84+
//// public foo() {
85+
//// return 30;
86+
//// }
87+
//// }
88+
//// }
89+
//// export module m2 {
90+
//// export class c {
91+
//// public foo2() {
92+
//// return new complexM.m1.c();
93+
//// }
94+
//// }
95+
//// }
96+
////}
97+
////var myComp/*35*/lexVal = new compl/*36*/exM.m/*37*/2./*38*/c().f/*39*/oo2().f/*40*/oo();
98+
99+
goTo.marker('1');
100+
verify.quickInfoIs("module m1", "Module comment");
101+
102+
goTo.marker('2');
103+
verify.completionListContains("b", "(var) m1.b: number", "b's comment");
104+
verify.completionListContains("foo", "(function) foo(): number", "foo's comment");
105+
106+
goTo.marker('3');
107+
verify.currentSignatureHelpDocCommentIs("foo's comment");
108+
goTo.marker('3q');
109+
verify.quickInfoIs("(function) foo(): number", "foo's comment");
110+
111+
goTo.marker('4');
112+
verify.completionListContains("m1", "module m1", "Module comment");
113+
114+
goTo.marker('5');
115+
verify.memberListContains("b", "(var) m1.b: number", "b's comment");
116+
verify.memberListContains("fooExport", "(function) m1.fooExport(): number", "exported function");
117+
verify.memberListContains("m2", "module m1.m2");
118+
verify.quickInfoIs("(function) m1.fooExport(): number", "exported function");
119+
120+
goTo.marker('6');
121+
verify.currentSignatureHelpDocCommentIs("exported function");
122+
123+
goTo.marker('7');
124+
verify.quickInfoIs("(var) myvar: m1.m2.c", "");
125+
126+
goTo.marker('8');
127+
verify.quickInfoIs("(constructor) m1.m2.c(): m1.m2.c", "");
128+
verify.memberListContains("c", "class m1.m2.c", "class comment;");
129+
verify.memberListContains("i", "(var) m1.m2.i: m1.m2.c", "i");
130+
131+
goTo.marker('9');
132+
verify.completionListContains("m2", "module m2", "");
133+
verify.quickInfoIs("module m2", "");
134+
135+
goTo.marker('10');
136+
verify.memberListContains("m3", "module m2.m3");
137+
verify.quickInfoIs("module m2.m3", "module comment of m2.m3");
138+
139+
goTo.marker('11');
140+
verify.quickInfoIs("(constructor) m2.m3.c(): m2.m3.c", "");
141+
verify.memberListContains("c", "class m2.m3.c", "Exported class comment");
142+
143+
goTo.marker('12');
144+
verify.completionListContains("m3", "module m3", "");
145+
verify.quickInfoIs("module m3", "");
146+
147+
goTo.marker('13');
148+
verify.memberListContains("m4", "module m3.m4", "");
149+
verify.quickInfoIs("module m3.m4", "");
150+
151+
goTo.marker('14');
152+
verify.memberListContains("m5", "module m3.m4.m5");
153+
verify.quickInfoIs("module m3.m4.m5", "module comment of m3.m4.m5");
154+
155+
goTo.marker('15');
156+
verify.memberListContains("c", "class m3.m4.m5.c", "Exported class comment");
157+
verify.quickInfoIs("(constructor) m3.m4.m5.c(): m3.m4.m5.c", "");
158+
159+
goTo.marker('16');
160+
verify.completionListContains("m4", "module m4", "");
161+
verify.quickInfoIs("module m4", "");
162+
163+
goTo.marker('17');
164+
verify.memberListContains("m5", "module m4.m5", "");
165+
verify.quickInfoIs("module m4.m5", "");
166+
167+
goTo.marker('18');
168+
verify.memberListContains("m6", "module m4.m5.m6");
169+
verify.quickInfoIs("module m4.m5.m6", "module comment of m4.m5.m6");
170+
171+
goTo.marker('19');
172+
verify.memberListContains("m7", "module m4.m5.m6.m7");
173+
verify.quickInfoIs("module m4.m5.m6.m7", "");
174+
175+
goTo.marker('20');
176+
verify.memberListContains("c", "class m4.m5.m6.m7.c", "Exported class comment");
177+
verify.quickInfoIs("(constructor) m4.m5.m6.m7.c(): m4.m5.m6.m7.c", "");
178+
179+
goTo.marker('21');
180+
verify.completionListContains("m5", "module m5");
181+
verify.quickInfoIs("module m5", "");
182+
183+
goTo.marker('22');
184+
verify.memberListContains("m6", "module m5.m6");
185+
verify.quickInfoIs("module m5.m6", "");
186+
187+
goTo.marker('23');
188+
verify.memberListContains("m7", "module m5.m6.m7");
189+
verify.quickInfoIs("module m5.m6.m7", "module comment of m5.m6.m7");
190+
191+
goTo.marker('24');
192+
verify.memberListContains("m8", "module m5.m6.m7.m8");
193+
verify.quickInfoIs("module m5.m6.m7.m8", "module m8 comment");
194+
195+
goTo.marker('25');
196+
verify.memberListContains("c", "class m5.m6.m7.m8.c", "Exported class comment");
197+
verify.quickInfoIs("(constructor) m5.m6.m7.m8.c(): m5.m6.m7.m8.c", "");
198+
199+
goTo.marker('26');
200+
verify.completionListContains("m6", "module m6");
201+
verify.quickInfoIs("module m6", "");
202+
203+
goTo.marker('27');
204+
verify.memberListContains("m7", "module m6.m7");
205+
verify.quickInfoIs("module m6.m7", "");
206+
207+
goTo.marker('28');
208+
verify.memberListContains("m8", "module m6.m7.m8");
209+
verify.quickInfoIs("module m6.m7.m8", "");
210+
211+
goTo.marker('29');
212+
verify.memberListContains("c", "class m6.m7.m8.c", "Exported class comment");
213+
verify.quickInfoIs("(constructor) m6.m7.m8.c(): m6.m7.m8.c", "");
214+
215+
goTo.marker('30');
216+
verify.completionListContains("m7", "module m7");
217+
verify.quickInfoIs("module m7", "");
218+
219+
goTo.marker('31');
220+
verify.memberListContains("m8", "module m7.m8");
221+
verify.quickInfoIs("module m7.m8", "");
222+
223+
goTo.marker('32');
224+
verify.memberListContains("m9", "module m7.m8.m9");
225+
verify.quickInfoIs("module m7.m8.m9", "module m9 comment");
226+
227+
goTo.marker('33');
228+
verify.memberListContains("c", "class m7.m8.m9.c", "Exported class comment");
229+
verify.quickInfoIs("(constructor) m7.m8.m9.c(): m7.m8.m9.c", "");
230+
231+
goTo.marker('34');
232+
verify.completionListContains("c", 'class c', "");
233+
verify.quickInfoIs('class c', "");
234+
235+
goTo.marker('35');
236+
verify.quickInfoIs("(var) myComplexVal: number", "");
237+
238+
goTo.marker('36');
239+
verify.quickInfoIs("module complexM", "");
240+
241+
goTo.marker('37');
242+
verify.quickInfoIs("module complexM.m2", "");
243+
244+
goTo.marker('38');
245+
verify.quickInfoIs("(constructor) complexM.m2.c(): complexM.m2.c", "");
246+
247+
goTo.marker('39');
248+
verify.quickInfoIs("(method) complexM.m2.c.foo2(): complexM.m1.c", "");
249+
250+
goTo.marker('40');
251+
verify.quickInfoIs("(method) complexM.m1.c.foo(): number", "");

0 commit comments

Comments
 (0)