@@ -361,21 +361,25 @@ namespace ts.Completions {
361
361
position : number ,
362
362
{ name, source } : CompletionEntryIdentifier ,
363
363
allSourceFiles : ReadonlyArray < SourceFile > ,
364
- ) : { symbol : Symbol , location : Node , symbolToOriginInfoMap : SymbolOriginInfoMap } | undefined {
364
+ ) : { type : " symbol" , symbol : Symbol , location : Node , symbolToOriginInfoMap : SymbolOriginInfoMap } | { type : "request" , request : Request } | { type : "none" } {
365
365
const completionData = getCompletionData ( typeChecker , log , sourceFile , position , allSourceFiles ) ;
366
366
if ( ! completionData ) {
367
- return undefined ;
367
+ return { type : "none" } ;
368
+ }
369
+
370
+ const { symbols, location, allowStringLiteral, symbolToOriginInfoMap, request } = completionData ;
371
+ if ( request ) {
372
+ return { type : "request" , request } ;
368
373
}
369
374
370
- const { symbols, location, allowStringLiteral, symbolToOriginInfoMap } = completionData ;
371
375
// Find the symbol with the matching entry name.
372
376
// We don't need to perform character checks here because we're only comparing the
373
377
// name against 'entryName' (which is known to be good), not building a new
374
378
// completion entry.
375
379
const symbol = find ( symbols , s =>
376
380
getCompletionEntryDisplayNameForSymbol ( s , compilerOptions . target , /*performCharacterChecks*/ false , allowStringLiteral ) === name
377
381
&& getSourceFromOrigin ( symbolToOriginInfoMap [ getSymbolId ( s ) ] ) === source ) ;
378
- return symbol && { symbol, location, symbolToOriginInfoMap } ;
382
+ return symbol ? { type : " symbol" , symbol , location, symbolToOriginInfoMap } : { type : "none" } ;
379
383
}
380
384
381
385
export interface CompletionEntryIdentifier {
@@ -397,29 +401,44 @@ namespace ts.Completions {
397
401
const { name, source } = entryId ;
398
402
// Compute all the completion symbols again.
399
403
const symbolCompletion = getSymbolCompletionFromEntryId ( typeChecker , log , compilerOptions , sourceFile , position , entryId , allSourceFiles ) ;
400
- if ( symbolCompletion ) {
401
- const { symbol, location, symbolToOriginInfoMap } = symbolCompletion ;
402
- const codeActions = getCompletionEntryCodeActions ( symbolToOriginInfoMap , symbol , typeChecker , host , compilerOptions , sourceFile , rulesProvider ) ;
403
- const kindModifiers = SymbolDisplay . getSymbolModifiers ( symbol ) ;
404
- const { displayParts, documentation, symbolKind, tags } = SymbolDisplay . getSymbolDisplayPartsDocumentationAndSymbolKind ( typeChecker , symbol , sourceFile , location , location , SemanticMeaning . All ) ;
405
- return { name, kindModifiers, kind : symbolKind , displayParts, documentation, tags, codeActions, source : source === undefined ? undefined : [ textPart ( source ) ] } ;
406
- }
407
-
408
- // Didn't find a symbol with this name. See if we can find a keyword instead.
409
- if ( source === undefined && some ( getKeywordCompletions ( KeywordCompletionFilters . None ) , c => c . name === name ) ) {
410
- return {
411
- name,
412
- kind : ScriptElementKind . keyword ,
413
- kindModifiers : ScriptElementKindModifier . none ,
414
- displayParts : [ displayPart ( name , SymbolDisplayPartKind . keyword ) ] ,
415
- documentation : undefined ,
416
- tags : undefined ,
417
- codeActions : undefined ,
418
- source : undefined ,
419
- } ;
404
+ switch ( symbolCompletion . type ) {
405
+ case "request" : {
406
+ const { request } = symbolCompletion ;
407
+ switch ( request . kind ) {
408
+ case "JsDocTagName" :
409
+ return JsDoc . getJSDocTagNameCompletionDetails ( name ) ;
410
+ case "JsDocTag" :
411
+ return JsDoc . getJSDocTagCompletionDetails ( name ) ;
412
+ case "JsDocParameterName" :
413
+ return JsDoc . getJSDocParameterNameCompletionDetails ( name ) ;
414
+ default :
415
+ return Debug . assertNever ( request ) ;
416
+ }
417
+ }
418
+ case "symbol" : {
419
+ const { symbol, location, symbolToOriginInfoMap } = symbolCompletion ;
420
+ const codeActions = getCompletionEntryCodeActions ( symbolToOriginInfoMap , symbol , typeChecker , host , compilerOptions , sourceFile , rulesProvider ) ;
421
+ const kindModifiers = SymbolDisplay . getSymbolModifiers ( symbol ) ;
422
+ const { displayParts, documentation, symbolKind, tags } = SymbolDisplay . getSymbolDisplayPartsDocumentationAndSymbolKind ( typeChecker , symbol , sourceFile , location , location , SemanticMeaning . All ) ;
423
+ return { name, kindModifiers, kind : symbolKind , displayParts, documentation, tags, codeActions, source : source === undefined ? undefined : [ textPart ( source ) ] } ;
424
+ }
425
+ case "none" : {
426
+ // Didn't find a symbol with this name. See if we can find a keyword instead.
427
+ if ( some ( getKeywordCompletions ( KeywordCompletionFilters . None ) , c => c . name === name ) ) {
428
+ return {
429
+ name,
430
+ kind : ScriptElementKind . keyword ,
431
+ kindModifiers : ScriptElementKindModifier . none ,
432
+ displayParts : [ displayPart ( name , SymbolDisplayPartKind . keyword ) ] ,
433
+ documentation : undefined ,
434
+ tags : undefined ,
435
+ codeActions : undefined ,
436
+ source : undefined ,
437
+ } ;
438
+ }
439
+ return undefined ;
440
+ }
420
441
}
421
-
422
- return undefined ;
423
442
}
424
443
425
444
function getCompletionEntryCodeActions (
@@ -461,16 +480,16 @@ namespace ts.Completions {
461
480
allSourceFiles : ReadonlyArray < SourceFile > ,
462
481
) : Symbol | undefined {
463
482
const completion = getSymbolCompletionFromEntryId ( typeChecker , log , compilerOptions , sourceFile , position , entryId , allSourceFiles ) ;
464
- return completion && completion . symbol ;
483
+ return completion . type === "symbol" ? completion . symbol : undefined ;
465
484
}
466
485
467
486
interface CompletionData {
468
- symbols : Symbol [ ] ;
487
+ symbols : ReadonlyArray < Symbol > ;
469
488
isGlobalCompletion : boolean ;
470
489
isMemberCompletion : boolean ;
471
490
allowStringLiteral : boolean ;
472
491
isNewIdentifierLocation : boolean ;
473
- location : Node ;
492
+ location : Node | undefined ;
474
493
isRightOfDot : boolean ;
475
494
request ?: Request ;
476
495
keywordFilters : KeywordCompletionFilters ;
@@ -557,7 +576,7 @@ namespace ts.Completions {
557
576
558
577
if ( request ) {
559
578
return {
560
- symbols : undefined ,
579
+ symbols : emptyArray ,
561
580
isGlobalCompletion : false ,
562
581
isMemberCompletion : false ,
563
582
allowStringLiteral : false ,
0 commit comments