File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,10 @@ namespace ts {
301
301
return node . kind >= SyntaxKind . FirstJSDocNode && node . kind <= SyntaxKind . LastJSDocNode ;
302
302
}
303
303
304
+ export function isJSDocTag ( node : Node ) {
305
+ return node . kind >= SyntaxKind . FirstJSDocTagNode && node . kind <= SyntaxKind . LastJSDocTagNode ;
306
+ }
307
+
304
308
export function getNonDecoratorTokenPosOfNode ( node : Node , sourceFile ?: SourceFile ) : number {
305
309
if ( nodeIsMissing ( node ) || ! node . decorators ) {
306
310
return getTokenPosOfNode ( node , sourceFile ) ;
Original file line number Diff line number Diff line change @@ -299,6 +299,10 @@ namespace ts {
299
299
processNode ( jsDocComment ) ;
300
300
}
301
301
}
302
+ // For syntactic classifications, all trivia are classcified together, including jsdoc comments.
303
+ // For that to work, the jsdoc comments should still be the leading trivia of the first child.
304
+ // Restoring the scanner position ensures that.
305
+ pos = this . pos ;
302
306
forEachChild ( this , processNode , processNodes ) ;
303
307
if ( pos < this . end ) {
304
308
this . addSyntheticNodes ( children , pos , this . end ) ;
@@ -7596,6 +7600,10 @@ namespace ts {
7596
7600
* False will mean that node is not classified and traverse routine should recurse into node contents.
7597
7601
*/
7598
7602
function tryClassifyNode ( node : Node ) : boolean {
7603
+ if ( isJSDocTag ( node ) ) {
7604
+ return true ;
7605
+ }
7606
+
7599
7607
if ( nodeIsMissing ( node ) ) {
7600
7608
return true ;
7601
7609
}
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts"/>
2
+
3
+ //// /** @param {number } p1 */
4
+ //// function foo(p1) {}
5
+
6
+ var c = classification ;
7
+ verify . syntacticClassificationsAre (
8
+ c . comment ( "/** " ) ,
9
+ c . punctuation ( "@" ) ,
10
+ c . docCommentTagName ( "param" ) ,
11
+ c . comment ( " " ) ,
12
+ c . punctuation ( "{" ) ,
13
+ c . keyword ( "number" ) ,
14
+ c . punctuation ( "}" ) ,
15
+ c . comment ( " " ) ,
16
+ c . parameterName ( "p1" ) ,
17
+ c . comment ( " */" ) ,
18
+ c . keyword ( "function" ) ,
19
+ c . identifier ( "foo" ) ,
20
+ c . punctuation ( "(" ) ,
21
+ c . parameterName ( "p1" ) ,
22
+ c . punctuation ( ")" ) ,
23
+ c . punctuation ( "{" ) ,
24
+ c . punctuation ( "}" ) ) ;
You can’t perform that action at this time.
0 commit comments