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 {
301301 return node . kind >= SyntaxKind . FirstJSDocNode && node . kind <= SyntaxKind . LastJSDocNode ;
302302 }
303303
304+ export function isJSDocTag ( node : Node ) {
305+ return node . kind >= SyntaxKind . FirstJSDocTagNode && node . kind <= SyntaxKind . LastJSDocTagNode ;
306+ }
307+
304308 export function getNonDecoratorTokenPosOfNode ( node : Node , sourceFile ?: SourceFile ) : number {
305309 if ( nodeIsMissing ( node ) || ! node . decorators ) {
306310 return getTokenPosOfNode ( node , sourceFile ) ;
Original file line number Diff line number Diff line change @@ -299,6 +299,10 @@ namespace ts {
299299 processNode ( jsDocComment ) ;
300300 }
301301 }
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 ;
302306 forEachChild ( this , processNode , processNodes ) ;
303307 if ( pos < this . end ) {
304308 this . addSyntheticNodes ( children , pos , this . end ) ;
@@ -7596,6 +7600,10 @@ namespace ts {
75967600 * False will mean that node is not classified and traverse routine should recurse into node contents.
75977601 */
75987602 function tryClassifyNode ( node : Node ) : boolean {
7603+ if ( isJSDocTag ( node ) ) {
7604+ return true ;
7605+ }
7606+
75997607 if ( nodeIsMissing ( node ) ) {
76007608 return true ;
76017609 }
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