File tree Expand file tree Collapse file tree 11 files changed +294
-14
lines changed
tests/baselines/reference/JSDocParsing Expand file tree Collapse file tree 11 files changed +294
-14
lines changed Original file line number Diff line number Diff line change @@ -7532,6 +7532,7 @@ namespace ts {
7532
7532
function parseTagComments ( indent : number , initialMargin ?: string ) : string | undefined {
7533
7533
const comments : string [ ] = [ ] ;
7534
7534
let state = JSDocState . BeginningOfLine ;
7535
+ let previousWhitespace = true ;
7535
7536
let margin : number | undefined ;
7536
7537
function pushComment ( text : string ) {
7537
7538
if ( ! margin ) {
@@ -7557,7 +7558,8 @@ namespace ts {
7557
7558
indent = 0 ;
7558
7559
break ;
7559
7560
case SyntaxKind . AtToken :
7560
- if ( state === JSDocState . SavingBackticks ) {
7561
+ if ( state === JSDocState . SavingBackticks || ! previousWhitespace && state === JSDocState . SavingComments ) {
7562
+ // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace
7561
7563
comments . push ( scanner . getTokenText ( ) ) ;
7562
7564
break ;
7563
7565
}
@@ -7614,6 +7616,7 @@ namespace ts {
7614
7616
pushComment ( scanner . getTokenText ( ) ) ;
7615
7617
break ;
7616
7618
}
7619
+ previousWhitespace = token ( ) === SyntaxKind . WhitespaceTrivia ;
7617
7620
tok = nextTokenJSDoc ( ) ;
7618
7621
}
7619
7622
Original file line number Diff line number Diff line change @@ -331,7 +331,7 @@ namespace ts {
331
331
* Comments
332
332
* @author Early Close Caret > <a@b>
333
333
* @author No Line Breaks:
334
- * <the. email@address> must be on the same line to parse
334
+ * <the email @address> must be on the same line to parse
335
335
* @author Long Comment <[email protected] > I
336
336
* want to keep commenting down here, I dunno.
337
337
*/` ) ;
@@ -340,6 +340,22 @@ namespace ts {
340
340
`/**
341
341
* @example
342
342
* Some\n\n * text\r\n * with newlines.
343
+ */` ) ;
344
+ parsesCorrectly ( "Chained tags, no leading whitespace" , `/**@a @b @c@d*/` ) ;
345
+ parsesCorrectly ( "Initial star is not a tag" , `/***@a*/` ) ;
346
+ parsesCorrectly ( "Initial star space is not a tag" , `/*** @a*/` ) ;
347
+ parsesCorrectly ( "Initial email address is not a tag" , `/**[email protected] */` ) ;
348
+ parsesCorrectly ( "no space before @ is not a new tag" ,
349
+ `/**
350
+ * @param this (@is@)
351
+ * @param fine its@fine
352
+ @zerowidth
353
+ *@singlestar
354
+ **@doublestar
355
+ */` ) ;
356
+ parsesCorrectly ( "@@ does not start a new tag" ,
357
+ `/**
358
+ * @param this is (@@fine@@and) is one comment
343
359
*/` ) ;
344
360
} ) ;
345
361
} ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "kind" : " JSDocComment" ,
3
+ "pos" : 0 ,
4
+ "end" : 54 ,
5
+ "flags" : " JSDoc" ,
6
+ "modifierFlagsCache" : 0 ,
7
+ "transformFlags" : 0 ,
8
+ "tags" : {
9
+ "0" : {
10
+ "kind" : " JSDocParameterTag" ,
11
+ "pos" : 7 ,
12
+ "end" : 52 ,
13
+ "modifierFlagsCache" : 0 ,
14
+ "transformFlags" : 0 ,
15
+ "tagName" : {
16
+ "kind" : " Identifier" ,
17
+ "pos" : 8 ,
18
+ "end" : 13 ,
19
+ "modifierFlagsCache" : 0 ,
20
+ "transformFlags" : 0 ,
21
+ "escapedText" : " param"
22
+ },
23
+ "comment" : " is (@@fine@@and) is one comment" ,
24
+ "name" : {
25
+ "kind" : " Identifier" ,
26
+ "pos" : 14 ,
27
+ "end" : 18 ,
28
+ "modifierFlagsCache" : 0 ,
29
+ "transformFlags" : 0 ,
30
+ "originalKeywordKind" : " ThisKeyword" ,
31
+ "escapedText" : " this"
32
+ },
33
+ "isNameFirst" : true ,
34
+ "isBracketed" : false
35
+ },
36
+ "length" : 1 ,
37
+ "pos" : 7 ,
38
+ "end" : 52 ,
39
+ "hasTrailingComma" : false ,
40
+ "transformFlags" : 0
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "kind" : " JSDocComment" ,
3
+ "pos" : 0 ,
4
+ "end" : 15 ,
5
+ "flags" : " JSDoc" ,
6
+ "modifierFlagsCache" : 0 ,
7
+ "transformFlags" : 0 ,
8
+ "tags" : {
9
+ "0" : {
10
+ "kind" : " JSDocTag" ,
11
+ "pos" : 3 ,
12
+ "end" : 6 ,
13
+ "modifierFlagsCache" : 0 ,
14
+ "transformFlags" : 0 ,
15
+ "tagName" : {
16
+ "kind" : " Identifier" ,
17
+ "pos" : 4 ,
18
+ "end" : 5 ,
19
+ "modifierFlagsCache" : 0 ,
20
+ "transformFlags" : 0 ,
21
+ "escapedText" : " a"
22
+ }
23
+ },
24
+ "1" : {
25
+ "kind" : " JSDocTag" ,
26
+ "pos" : 6 ,
27
+ "end" : 9 ,
28
+ "modifierFlagsCache" : 0 ,
29
+ "transformFlags" : 0 ,
30
+ "tagName" : {
31
+ "kind" : " Identifier" ,
32
+ "pos" : 7 ,
33
+ "end" : 8 ,
34
+ "modifierFlagsCache" : 0 ,
35
+ "transformFlags" : 0 ,
36
+ "escapedText" : " b"
37
+ }
38
+ },
39
+ "2" : {
40
+ "kind" : " JSDocTag" ,
41
+ "pos" : 9 ,
42
+ "end" : 11 ,
43
+ "modifierFlagsCache" : 0 ,
44
+ "transformFlags" : 0 ,
45
+ "tagName" : {
46
+ "kind" : " Identifier" ,
47
+ "pos" : 10 ,
48
+ "end" : 11 ,
49
+ "modifierFlagsCache" : 0 ,
50
+ "transformFlags" : 0 ,
51
+ "escapedText" : " c"
52
+ }
53
+ },
54
+ "3" : {
55
+ "kind" : " JSDocTag" ,
56
+ "pos" : 11 ,
57
+ "end" : 13 ,
58
+ "modifierFlagsCache" : 0 ,
59
+ "transformFlags" : 0 ,
60
+ "tagName" : {
61
+ "kind" : " Identifier" ,
62
+ "pos" : 12 ,
63
+ "end" : 13 ,
64
+ "modifierFlagsCache" : 0 ,
65
+ "transformFlags" : 0 ,
66
+ "escapedText" : " d"
67
+ }
68
+ },
69
+ "length" : 4 ,
70
+ "pos" : 3 ,
71
+ "end" : 13 ,
72
+ "hasTrailingComma" : false ,
73
+ "transformFlags" : 0
74
+ }
75
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "kind" : " JSDocComment" ,
3
+ "pos" : 0 ,
4
+ "end" : 21 ,
5
+ "flags" : " JSDoc" ,
6
+ "modifierFlagsCache" : 0 ,
7
+ "transformFlags" : 0 ,
8
+
9
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "kind" : " JSDocComment" ,
3
+ "pos" : 0 ,
4
+ "end" : 8 ,
5
+ "flags" : " JSDoc" ,
6
+ "modifierFlagsCache" : 0 ,
7
+ "transformFlags" : 0 ,
8
+ "comment" : " *@a"
9
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "kind" : " JSDocComment" ,
3
+ "pos" : 0 ,
4
+ "end" : 8 ,
5
+ "flags" : " JSDoc" ,
6
+ "modifierFlagsCache" : 0 ,
7
+ "transformFlags" : 0 ,
8
+ "comment" : " *@a"
9
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "kind" : " JSDocComment" ,
3
+ "pos" : 0 ,
4
+ "end" : 9 ,
5
+ "flags" : " JSDoc" ,
6
+ "modifierFlagsCache" : 0 ,
7
+ "transformFlags" : 0 ,
8
+ "comment" : " * @a"
9
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "kind" : " JSDocComment" ,
3
+ "pos" : 0 ,
4
+ "end" : 9 ,
5
+ "flags" : " JSDoc" ,
6
+ "modifierFlagsCache" : 0 ,
7
+ "transformFlags" : 0 ,
8
+ "comment" : " * @a"
9
+ }
Original file line number Diff line number Diff line change 1
1
{
2
2
"kind" : " JSDocComment" ,
3
3
"pos" : 0 ,
4
- "end" : 738 ,
4
+ "end" : 739 ,
5
5
"flags" : " JSDoc" ,
6
6
"modifierFlagsCache" : 0 ,
7
7
"transformFlags" : 0 ,
262
262
"16" : {
263
263
"kind" : " JSDocAuthorTag" ,
264
264
"pos" : 559 ,
265
- "end" : 598 ,
265
+ "end" : 599 ,
266
266
"modifierFlagsCache" : 0 ,
267
267
"transformFlags" : 0 ,
268
268
"tagName" : {
273
273
"transformFlags" : 0 ,
274
274
"escapedText" : " author"
275
275
},
276
- "comment" : " No Line Breaks:<the. email"
276
+ "comment" : " No Line Breaks:<the email"
277
277
},
278
278
"17" : {
279
279
"kind" : " JSDocTag" ,
280
- "pos" : 598 ,
281
- "end" : 606 ,
280
+ "pos" : 599 ,
281
+ "end" : 607 ,
282
282
"modifierFlagsCache" : 0 ,
283
283
"transformFlags" : 0 ,
284
284
"tagName" : {
285
285
"kind" : " Identifier" ,
286
- "pos" : 599 ,
287
- "end" : 606 ,
286
+ "pos" : 600 ,
287
+ "end" : 607 ,
288
288
"modifierFlagsCache" : 0 ,
289
289
"transformFlags" : 0 ,
290
290
"escapedText" : " address"
293
293
},
294
294
"18" : {
295
295
"kind" : " JSDocAuthorTag" ,
296
- "pos" : 645 ,
297
- "end" : 736 ,
296
+ "pos" : 646 ,
297
+ "end" : 737 ,
298
298
"modifierFlagsCache" : 0 ,
299
299
"transformFlags" : 0 ,
300
300
"tagName" : {
301
301
"kind" : " Identifier" ,
302
- "pos" : 646 ,
303
- "end" : 652 ,
302
+ "pos" : 647 ,
303
+ "end" : 653 ,
304
304
"modifierFlagsCache" : 0 ,
305
305
"transformFlags" : 0 ,
306
306
"escapedText" : " author"
309
309
},
310
310
"length" : 19 ,
311
311
"pos" : 7 ,
312
- "end" : 736 ,
312
+ "end" : 737 ,
313
313
"hasTrailingComma" : false ,
314
314
"transformFlags" : 0
315
315
}
You can’t perform that action at this time.
0 commit comments