@@ -16,11 +16,16 @@ namespace ts.Completions {
1616 return undefined ;
1717 }
1818
19- const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName , shouldAppendAtSignBeforeJsDocTagName } = completionData ;
19+ const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName , requestJsDocTag } = completionData ;
2020
21- if ( isJsDocTagName ) {
21+ if ( requestJsDocTagName ) {
2222 // If the current position is a jsDoc tag name, only tag names should be provided for completion
23- return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries : JsDoc . getAllJsDocCompletionEntries ( shouldAppendAtSignBeforeJsDocTagName ) } ;
23+ return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries : JsDoc . getJSDocTagNameCompletions ( ) } ;
24+ }
25+
26+ if ( requestJsDocTag ) {
27+ // If the current position is a jsDoc tag, only tags should be provided for completion
28+ return { isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , entries : JsDoc . getJSDocTagCompletions ( ) } ;
2429 }
2530
2631 const entries : CompletionEntry [ ] = [ ] ;
@@ -54,7 +59,7 @@ namespace ts.Completions {
5459 }
5560
5661 // Add keywords if this is not a member completion list
57- if ( ! isMemberCompletion && ! isJsDocTagName ) {
62+ if ( ! isMemberCompletion && ! ( requestJsDocTag && requestJsDocTagName ) ) {
5863 addRange ( entries , keywordCompletions ) ;
5964 }
6065
@@ -814,13 +819,10 @@ namespace ts.Completions {
814819 function getCompletionData ( typeChecker : TypeChecker , log : ( message : string ) => void , sourceFile : SourceFile , position : number ) {
815820 const isJavaScriptFile = isSourceFileJavaScript ( sourceFile ) ;
816821
817- let isJsDocTagName = false ;
818- // This is for the case when users request completion in JsDoc without "@"
819- // i.e.
820- // /**
821- // * |completion here|
822- // **/
823- let shouldAppendAtSignBeforeJsDocTagName = false ;
822+ // JsDoc tag-name is just the name of the JSDoc tagname (exclude "@")
823+ let requestJsDocTagName = false ;
824+ // JsDoc tag includes both "@" and tag-name
825+ let requestJsDocTag = false ;
824826
825827 let start = timestamp ( ) ;
826828 const currentToken = getTokenAtPosition ( sourceFile , position ) ;
@@ -836,15 +838,27 @@ namespace ts.Completions {
836838 // The current position is next to the '@' sign, when no tag name being provided yet.
837839 // Provide a full list of tag names
838840 if ( sourceFile . text . charCodeAt ( position - 1 ) === CharacterCodes . at ) {
839- isJsDocTagName = true ;
841+ requestJsDocTagName = true ;
840842 }
841843 else {
844+ // When completion is requested without "@", we will have check to make sure that
845+ // there are no comments prefix the request position. We will only allow "*" and space.
846+ // e.g
847+ // /** |c| /*
848+ //
849+ // /**
850+ // |c|
851+ // */
852+ //
853+ // /**
854+ // * |c|
855+ // */
856+ //
857+ // /**
858+ // * |c|
859+ // */
842860 const lineStart = getLineStartPositionForPosition ( position , sourceFile ) ;
843- shouldAppendAtSignBeforeJsDocTagName = sourceFile . text . substr ( lineStart , position ) . indexOf ( "@" ) === - 1 ;
844-
845- if ( shouldAppendAtSignBeforeJsDocTagName ) {
846- isJsDocTagName = true ;
847- }
861+ requestJsDocTag = ! ( sourceFile . text . substr ( lineStart , position ) . match ( / [ ^ \* | \s | ( / \* \* ) ] / ) ) ;
848862 }
849863 }
850864
@@ -855,7 +869,7 @@ namespace ts.Completions {
855869 const tag = getJsDocTagAtPosition ( sourceFile , position ) ;
856870 if ( tag ) {
857871 if ( tag . tagName . pos <= position && position <= tag . tagName . end ) {
858- isJsDocTagName = true ;
872+ requestJsDocTagName = true ;
859873 }
860874
861875 switch ( tag . kind ) {
@@ -870,8 +884,8 @@ namespace ts.Completions {
870884 }
871885 }
872886
873- if ( isJsDocTagName || shouldAppendAtSignBeforeJsDocTagName ) {
874- return { symbols : undefined , isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , location : undefined , isRightOfDot : false , isJsDocTagName , shouldAppendAtSignBeforeJsDocTagName } ;
887+ if ( requestJsDocTagName || requestJsDocTag ) {
888+ return { symbols : undefined , isGlobalCompletion : false , isMemberCompletion : false , isNewIdentifierLocation : false , location : undefined , isRightOfDot : false , requestJsDocTagName , requestJsDocTag } ;
875889 }
876890
877891 if ( ! insideJsDocTagExpression ) {
@@ -999,7 +1013,7 @@ namespace ts.Completions {
9991013
10001014 log ( "getCompletionData: Semantic work: " + ( timestamp ( ) - semanticStart ) ) ;
10011015
1002- return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot : ( isRightOfDot || isRightOfOpenTag ) , isJsDocTagName , shouldAppendAtSignBeforeJsDocTagName } ;
1016+ return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot : ( isRightOfDot || isRightOfOpenTag ) , requestJsDocTagName , requestJsDocTag } ;
10031017
10041018 function getTypeScriptMemberSymbols ( ) : void {
10051019 // Right of dot member completion list
0 commit comments