Skip to content

Commit 0bcf716

Browse files
committed
fourslash test (Temporary code
1 parent dd10253 commit 0bcf716

File tree

2 files changed

+155
-35
lines changed

2 files changed

+155
-35
lines changed

src/services/completions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ namespace ts.Completions {
876876
}
877877
else {
878878
const lineStart = getLineStartPositionForPosition(position, sourceFile);
879+
// or !/[^/\s\*]/.test(sourceFile.text.substring(lineStart, position))
879880
if (!(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/))) {
880881
return { kind: CompletionDataKind.JsDocTag };
881882
}

tests/cases/fourslash/completionsJsdocTag.ts

+154-35
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,97 @@
55
//// * /**/
66
//// */
77

8+
// cannot run fourslash test these cases because it doesn't recognize the marker
9+
//** /*invalidMarker1*/*/
10+
//
11+
//** /*invalidMarker2*/*/
12+
//
813

9-
// jsdoc tags are listed when there is more than one whitespace after "*"
14+
// 1x - jsdoc tags are listed when there is more than one whitespace after "*"
1015
/////**
11-
//// * /*1*/
16+
//// * /*10*/
1217
//// */
1318
////
1419
/////**
15-
//// * link to {/*2*/
20+
//// * /*11*/
1621
//// */
1722
////
1823

19-
// before the fix, jsdoc tag names was listed (but no longer appears
20-
// jsdoc tag names are still listed after the fix.
21-
// however this behavior does not by getCompletionData.insideComment.hasDocComment clause
22-
/////**@/*3*/ */
24+
// 2x - also, if there is more than one whitespace at the beginning of the line.
25+
/////**
26+
//// /*20*/
27+
//// */
2328
////
2429
/////**
25-
//// * @type {@/*4*/
30+
//// /*21*/
2631
//// */
2732
////
2833
/////**
29-
//// *@/*5*/
34+
//// /*22*/
3035
//// */
3136
////
3237

33-
// before the fix, jsdoc tags was listed but no longer appears
38+
// 3x - jsdoc tag names will be listed
39+
/////** @/*30*/ */
40+
////
41+
/////** @/*31*/ */
42+
////
3443
/////**
35-
//// +/*6*/
44+
//// * @/*32*/
3645
//// */
3746
////
3847
/////**
39-
//// */*7*/
48+
//// * @/*33*/
49+
//// */
50+
////
51+
/////**
52+
//// @/*34*/
53+
//// */
54+
////
55+
/////**
56+
//// @/*35*/
57+
//// */
58+
////
59+
/////**
60+
//// * @pa/*36*/
4061
//// */
4162
////
4263

43-
// jsdoc tag names will be listed
64+
// 4x - jsdoc tag name completions should not occur
65+
/////**@/*40*/ */
66+
////
67+
/////**
68+
//// *@/*41*/
69+
//// */
70+
////
4471
/////**
45-
//// * @/*8*/
72+
//// * @type {@/*42*/
73+
//// */
74+
////
75+
/////**
76+
//// +@/*43*/
77+
//// */
78+
////
79+
/////** some description @/*44*/ */
80+
////
81+
/////**
82+
//// * ### jsdoc @/*45*/
83+
//// */
84+
////
85+
86+
// 5x - jsdoc tag completions should not occur
87+
/////**
88+
//// */*50*/
4689
//// */
4790
////
4891

49-
// before the fix, jsdoc tag names was listed but no longer appears
92+
// also, can support the inline jsdoc tags
5093
/////**
51-
//// +@/*9*/
94+
//// * link to {/*70*/
5295
//// */
5396
////
5497
/////**
55-
//// * ### jsdoc @/*10*/
98+
//// * link to {@/*71*/
5699
//// */
57100
////
58101

@@ -64,39 +107,115 @@ verify.completions({ marker: "", includes: { name: "@property", text: "@property
64107
//
65108
test.markerNames().forEach(marker => {
66109
if (marker) {
110+
let completionOpt: FourSlashInterface.CompletionsOptions;
67111
const n = +marker;
68112
switch (n) {
69-
case 1:
70-
// case 2:
71-
verify.completions({ marker, includes: ["@abstract", "@access"] });
113+
/* https://coderwall.com/p/zbc2zw/the-comment-toggle-trick
114+
115+
// - - - - - -
116+
// before fix
117+
// - - - - - -
118+
119+
// jsdoc tags will be listed when there is more than one whitespace after "*"
120+
case 10: case 11:
121+
// also, if there is more than one whitespace at the beginning of the line.
122+
case 20: case 21: case 22:
123+
124+
// 5x - jsdoc tag completions should not occur
125+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
126+
// jsdoc tags will be listed but this does not the expected behavior
127+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
128+
case 50:
129+
completionOpt = { marker, includes: ["@abstract", "@access"] };
72130
break;
73-
case 3:
74-
// case 4:
75-
case 5:
76-
verify.completions({
131+
132+
// 3x - jsdoc tag names will be listed
133+
case 30: case 31: case 32: case 33: case 34: case 35: case 36:
134+
135+
// 4x - jsdoc tag name completions should not occur
136+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
137+
// jsdoc tag names will be listed but this does not the expected behavior
138+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139+
case 40: case 41: case 42: case 43: case 44: case 45:
140+
141+
// does not the expected behavior... because ts.JsDoc@jsDocTagNames is missing inline jsdoc tag name
142+
// In other words, inline jsdoc tag is interpreted as not intending to support
143+
case 71:
144+
completionOpt = {
77145
marker,
78146
triggerCharacter: "@",
79-
includes: ["abstract", "access"]
80-
});
147+
includes: ["package", "param"]
148+
};
81149
break;
82-
case 6: case 7:
83-
verify.completions({ marker, exact: [] });
150+
/*/
151+
152+
// - - - - - -
153+
// after fix
154+
// - - - - - -
155+
156+
// jsdoc tags will be listed when there is more than one whitespace after "*"
157+
case 10: case 11:
158+
// also, if there is more than one whitespace at the beginning of the line.
159+
case 20: case 21: case 22:
160+
161+
// // also, can support the inline jsdoc tags
162+
// case 70:
163+
completionOpt = { marker, includes: [
164+
"@abstract", "@access",
165+
// "@link"
166+
]};
84167
break;
85-
case 8:
86-
verify.completions({
168+
169+
// 3x - jsdoc tag names will be listed
170+
case 30: case 31: case 32: case 33: case 34: case 35:
171+
172+
// 4x - jsdoc tag name completions should not occur
173+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
174+
// this behavior does not by getCompletionData.insideComment.hasDocComment clause
175+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
176+
case 40: case 41: case 42:
177+
178+
// // also, can support the inline jsdoc tags
179+
// case 71:
180+
completionOpt = {
87181
marker,
88182
triggerCharacter: "@",
89183
includes: ["abstract", "access"]
90-
});
184+
};
91185
break;
92-
case 9: case 10:
93-
verify.completions({
186+
187+
// 4x - jsdoc tag name completions should not occur
188+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
189+
// before the fix, jsdoc tag names was listed but no longer appears
190+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
191+
case 43: case 44: case 45:
192+
completionOpt = {
94193
marker,
95194
triggerCharacter: "@",
96195
exact: []
97-
});
196+
};
197+
break;
198+
199+
// 5x - jsdoc tag completions should not occur
200+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
201+
// before the fix, jsdoc tags was listed but no longer appears
202+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
203+
case 50:
204+
completionOpt = { marker, exact: [] };
98205
break;
99-
default: break;
206+
//*/
207+
208+
default:
209+
break;
210+
}
211+
if (completionOpt) {
212+
// verify.completions(completionOpt);
213+
try {
214+
verify.completions(completionOpt);
215+
} catch (e) {
216+
console.log(e.message);
217+
console.log("please switch the code of src/services/completions.ts#getCompletionData");
218+
}
100219
}
101220
}
102221
});

0 commit comments

Comments
 (0)