File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ namespace ts {
132132
133133 let emptyArray : any [ ] = [ ] ;
134134
135- const jsDocTagNames : string [ ] = [
135+ const jsDocTagNames = [
136136 "augments" ,
137137 "author" ,
138138 "argument" ,
@@ -2992,7 +2992,7 @@ namespace ts {
29922992 let tagWithExpression = < JSDocTypeTag | JSDocParameterTag > tag ;
29932993 if ( tagWithExpression . typeExpression ) {
29942994 insideJsDocTagExpression = tagWithExpression . typeExpression . pos < position && position < tagWithExpression . typeExpression . end ;
2995- } ;
2995+ }
29962996 break ;
29972997 }
29982998 }
Original file line number Diff line number Diff line change @@ -470,26 +470,27 @@ namespace ts {
470470 }
471471
472472 /**
473- * Get the corresponding JSDocTag node if the position is in a jsDoc commet
473+ * Get the corresponding JSDocTag node if the position is in a jsDoc comment
474474 */
475475 export function getJsDocTagAtPosition ( sourceFile : SourceFile , position : number ) : JSDocTag {
476476 let node = ts . getTokenAtPosition ( sourceFile , position ) ;
477- let jsDocComment : JSDocComment ;
478- if ( node . jsDocComment ) {
479- jsDocComment = node . jsDocComment ;
480- }
481- else {
482- while ( node ) {
483- if ( node . kind === SyntaxKind . VariableStatement ||
484- node . kind === SyntaxKind . FunctionDeclaration ||
485- node . kind === SyntaxKind . Parameter ) {
486- jsDocComment = node . jsDocComment ;
477+ if ( isToken ( node ) ) {
478+ switch ( node . kind ) {
479+ case SyntaxKind . VarKeyword :
480+ case SyntaxKind . LetKeyword :
481+ case SyntaxKind . ConstKeyword :
482+ // if the current token is var, let or const, skip the VariableDeclarationList
483+ node = node . parent . parent ;
487484 break ;
488- }
485+ default :
486+ node = node . parent ;
487+ break ;
488+ }
489+ if ( ! node . jsDocComment ) {
489490 node = node . parent ;
490491 }
491492 }
492-
493+ let jsDocComment = node . jsDocComment ;
493494 if ( jsDocComment ) {
494495 for ( let tag of jsDocComment . tags ) {
495496 if ( tag . pos <= position && position <= tag . end ) {
You can’t perform that action at this time.
0 commit comments