Skip to content

Commit 3294c2b

Browse files
committed
Enable test cases for comments/type name format validation
1 parent c0138d1 commit 3294c2b

18 files changed

+2077
-2073
lines changed

src/services/services.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,14 @@ module ts {
249249

250250
getDocumentationComment(): SymbolDisplayPart[] {
251251
if (this.documentationComment === undefined) {
252-
this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name);
252+
this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & SymbolFlags.Property));
253253
}
254254

255255
return this.documentationComment;
256256
}
257257
}
258258

259-
function getJsDocCommentsFromDeclarations(declarations: Declaration[], name: string) {
259+
function getJsDocCommentsFromDeclarations(declarations: Declaration[], name: string, canUseParsedParamTagComments: boolean) {
260260
var documentationComment = <SymbolDisplayPart[]>[];
261261
var docComments = getJsDocCommentsSeparatedByNewLines();
262262
ts.forEach(docComments, docComment => {
@@ -275,7 +275,7 @@ module ts {
275275
ts.forEach(declarations, declaration => {
276276
var sourceFileOfDeclaration = getSourceFileOfNode(declaration);
277277
// If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments
278-
if (declaration.kind === SyntaxKind.Parameter) {
278+
if (canUseParsedParamTagComments && declaration.kind === SyntaxKind.Parameter) {
279279
ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), jsDocCommentTextRange => {
280280
var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
281281
if (cleanedParamJsDocComment) {
@@ -613,7 +613,10 @@ module ts {
613613

614614
getDocumentationComment(): SymbolDisplayPart[] {
615615
if (this.documentationComment === undefined) {
616-
this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], this.declaration.name ? this.declaration.name.text : "") : [];
616+
this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations(
617+
[this.declaration],
618+
this.declaration.name ? this.declaration.name.text : "",
619+
/*canUseParsedParamTagComments*/ false) : [];
617620
}
618621

619622
return this.documentationComment;
@@ -2689,9 +2692,7 @@ module ts {
26892692
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Signature || symbolFlags & SymbolFlags.Class) {
26902693
// If it is accessor they are allowed only if location is at name of the accessor
26912694
if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) {
2692-
if (!isNameOfFunctionDeclaration(location) || ts.contains(symbol.getDeclarations(), location.parent)) {
2693-
symbolKind = ScriptElementKind.memberVariableElement;
2694-
}
2695+
symbolKind = ScriptElementKind.memberVariableElement;
26952696
}
26962697

26972698
var type = typeResolver.getTypeOfSymbol(symbol);
@@ -2750,7 +2751,7 @@ module ts {
27502751
hasAddedSymbolInfo = true;
27512752
}
27522753
}
2753-
else if (isNameOfFunctionDeclaration(location) || // name of function declaration
2754+
else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & SymbolFlags.Accessor)) || // name of function declaration
27542755
(location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration
27552756
// get the signature from the declaration and write it
27562757
var signature: Signature;
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////** This is class c2 without constuctor*/
4+
////class c/*1*/2 {
5+
////}
6+
////var i/*2*/2 = new c/*28*/2(/*3*/);
7+
////var i2/*4*/_c = c/*5*/2;
8+
////class c/*6*/3 {
9+
//// /** Constructor comment*/
10+
//// constructor() {
11+
//// }
12+
////}
13+
////var i/*7*/3 = new c/*29*/3(/*8*/);
14+
////var i3/*9*/_c = c/*10*/3;
15+
/////** Class comment*/
16+
////class c/*11*/4 {
17+
//// /** Constructor comment*/
18+
//// constructor() {
19+
//// }
20+
////}
21+
////var i/*12*/4 = new c/*30*/4(/*13*/);
22+
////var i4/*14*/_c = c/*15*/4;
23+
/////** Class with statics*/
24+
////class c/*16*/5 {
25+
//// static s1: number;
26+
////}
27+
////var i/*17*/5 = new c/*31*/5(/*18*/);
28+
////var i5_/*19*/c = c/*20*/5;
29+
/////** class with statics and constructor*/
30+
////class c/*21*/6 {
31+
//// /** s1 comment*/
32+
//// static s1: number;
33+
//// /** constructor comment*/
34+
//// constructor() {
35+
//// }
36+
////}
37+
////var i/*22*/6 = new c/*32*/6(/*23*/);
38+
////var i6/*24*/_c = c/*25*/6;
39+
/////*26*/
40+
////class a {
41+
//// /**
42+
//// constructor for a
43+
//// @param a this is my a
44+
//// */
45+
//// constructor(a: string) {
46+
//// }
47+
////}
48+
////new a(/*27*/"Hello");
49+
////module m {
50+
//// export module m2 {
51+
//// /** class comment */
52+
//// export class c1 {
53+
//// /** constructor comment*/
54+
//// constructor() {
55+
//// }
56+
//// }
57+
//// }
58+
////}
59+
////var myVar = new m.m2.c/*33*/1();
60+
61+
// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed
62+
edit.insert('');
63+
64+
goTo.marker('1');
65+
verify.quickInfoIs("class c2", "This is class c2 without constuctor");
66+
67+
goTo.marker('2');
68+
verify.quickInfoIs("(var) i2: c2", "");
69+
70+
goTo.marker('3');
71+
verify.currentSignatureHelpDocCommentIs("");
72+
73+
goTo.marker('4');
74+
verify.quickInfoIs("(var) i2_c: typeof c2", "");
75+
76+
goTo.marker('5');
77+
verify.quickInfoIs("class c2", "This is class c2 without constuctor");
78+
79+
goTo.marker('6');
80+
verify.quickInfoIs("class c3", "");
81+
82+
goTo.marker('7');
83+
verify.quickInfoIs("(var) i3: c3", "");
84+
85+
goTo.marker('8');
86+
verify.currentSignatureHelpDocCommentIs("Constructor comment");
87+
88+
goTo.marker('9');
89+
verify.quickInfoIs("(var) i3_c: typeof c3", "");
90+
91+
goTo.marker('10');
92+
verify.quickInfoIs("class c3", "");
93+
94+
goTo.marker('11');
95+
verify.quickInfoIs("class c4", "Class comment");
96+
97+
goTo.marker('12');
98+
verify.quickInfoIs("(var) i4: c4", "");
99+
100+
goTo.marker('13');
101+
verify.currentSignatureHelpDocCommentIs("Constructor comment");
102+
103+
goTo.marker('14');
104+
verify.quickInfoIs("(var) i4_c: typeof c4", "");
105+
106+
goTo.marker('15');
107+
verify.quickInfoIs("class c4", "Class comment");
108+
109+
goTo.marker('16');
110+
verify.quickInfoIs("class c5", "Class with statics");
111+
112+
goTo.marker('17');
113+
verify.quickInfoIs("(var) i5: c5", "");
114+
115+
goTo.marker('18');
116+
verify.currentSignatureHelpDocCommentIs("");
117+
118+
goTo.marker('19');
119+
verify.quickInfoIs("(var) i5_c: typeof c5", "");
120+
121+
goTo.marker('20');
122+
verify.quickInfoIs("class c5", "Class with statics");
123+
124+
goTo.marker('21');
125+
verify.quickInfoIs("class c6", "class with statics and constructor");
126+
127+
goTo.marker('22');
128+
verify.quickInfoIs("(var) i6: c6", "");
129+
130+
goTo.marker('23');
131+
verify.currentSignatureHelpDocCommentIs("constructor comment");
132+
133+
goTo.marker('24');
134+
verify.quickInfoIs("(var) i6_c: typeof c6", "");
135+
136+
goTo.marker('25');
137+
verify.quickInfoIs("class c6", "class with statics and constructor");
138+
139+
goTo.marker('26');
140+
verify.completionListContains("c2", "class c2", "This is class c2 without constuctor");
141+
verify.completionListContains("i2", "(var) i2: c2", "");
142+
verify.completionListContains("i2_c", "(var) i2_c: typeof c2", "");
143+
verify.completionListContains("c3", "class c3", "");
144+
verify.completionListContains("i3", "(var) i3: c3", "");
145+
verify.completionListContains("i3_c", "(var) i3_c: typeof c3", "");
146+
verify.completionListContains("c4", "class c4", "Class comment");
147+
verify.completionListContains("i4", "(var) i4: c4", "");
148+
verify.completionListContains("i4_c", "(var) i4_c: typeof c4", "");
149+
verify.completionListContains("c5", "class c5", "Class with statics");
150+
verify.completionListContains("i5", "(var) i5: c5", "");
151+
verify.completionListContains("i5_c", "(var) i5_c: typeof c5");
152+
verify.completionListContains("c6", "class c6", "class with statics and constructor");
153+
verify.completionListContains("i6", "(var) i6: c6", "");
154+
verify.completionListContains("i6_c", "(var) i6_c: typeof c6", "");
155+
156+
goTo.marker('27');
157+
verify.currentSignatureHelpDocCommentIs("constructor for a");
158+
verify.currentParameterHelpArgumentDocCommentIs("this is my a");
159+
160+
goTo.marker('28');
161+
verify.quickInfoIs("(constructor) c2(): c2", "");
162+
163+
goTo.marker('29');
164+
verify.quickInfoIs("(constructor) c3(): c3", "Constructor comment");
165+
166+
goTo.marker('30');
167+
verify.quickInfoIs("(constructor) c4(): c4", "Constructor comment");
168+
169+
goTo.marker('31');
170+
verify.quickInfoIs("(constructor) c5(): c5", "");
171+
172+
goTo.marker('32');
173+
verify.quickInfoIs("(constructor) c6(): c6", "constructor comment");
174+
175+
goTo.marker('33');
176+
verify.quickInfoIs("(constructor) m.m2.c1(): m.m2.c1", "constructor comment");

0 commit comments

Comments
 (0)