@@ -422,8 +422,9 @@ namespace ts.Completions {
422
422
allSourceFiles : ReadonlyArray < SourceFile > ,
423
423
host : LanguageServiceHost ,
424
424
formatContext : formatting . FormatContext ,
425
+ getCanonicalFileName : GetCanonicalFileName ,
425
426
) : CompletionEntryDetails {
426
- const { name, source } = entryId ;
427
+ const { name } = entryId ;
427
428
// Compute all the completion symbols again.
428
429
const symbolCompletion = getSymbolCompletionFromEntryId ( typeChecker , log , compilerOptions , sourceFile , position , entryId , allSourceFiles ) ;
429
430
switch ( symbolCompletion . type ) {
@@ -442,10 +443,10 @@ namespace ts.Completions {
442
443
}
443
444
case "symbol" : {
444
445
const { symbol, location, symbolToOriginInfoMap } = symbolCompletion ;
445
- const codeActions = getCompletionEntryCodeActions ( symbolToOriginInfoMap , symbol , typeChecker , host , compilerOptions , sourceFile , formatContext ) ;
446
+ const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay ( symbolToOriginInfoMap , symbol , typeChecker , host , compilerOptions , sourceFile , formatContext , getCanonicalFileName ) ;
446
447
const kindModifiers = SymbolDisplay . getSymbolModifiers ( symbol ) ;
447
448
const { displayParts, documentation, symbolKind, tags } = SymbolDisplay . getSymbolDisplayPartsDocumentationAndSymbolKind ( typeChecker , symbol , sourceFile , location , location , SemanticMeaning . All ) ;
448
- return { name, kindModifiers, kind : symbolKind , displayParts, documentation, tags, codeActions, source : source === undefined ? undefined : [ textPart ( source ) ] } ;
449
+ return { name, kindModifiers, kind : symbolKind , displayParts, documentation, tags, codeActions, source : sourceDisplay } ;
449
450
}
450
451
case "none" : {
451
452
// Didn't find a symbol with this name. See if we can find a keyword instead.
@@ -466,33 +467,37 @@ namespace ts.Completions {
466
467
}
467
468
}
468
469
469
- function getCompletionEntryCodeActions (
470
+ function getCompletionEntryCodeActionsAndSourceDisplay (
470
471
symbolToOriginInfoMap : SymbolOriginInfoMap ,
471
472
symbol : Symbol ,
472
473
checker : TypeChecker ,
473
474
host : LanguageServiceHost ,
474
475
compilerOptions : CompilerOptions ,
475
476
sourceFile : SourceFile ,
476
477
formatContext : formatting . FormatContext ,
477
- ) : CodeAction [ ] | undefined {
478
+ getCanonicalFileName : GetCanonicalFileName ,
479
+ ) : { codeActions : CodeAction [ ] | undefined , sourceDisplay : SymbolDisplayPart [ ] | undefined } {
478
480
const symbolOriginInfo = symbolToOriginInfoMap [ getSymbolId ( symbol ) ] ;
479
481
if ( ! symbolOriginInfo ) {
480
- return undefined ;
482
+ return { codeActions : undefined , sourceDisplay : undefined } ;
481
483
}
482
484
483
485
const { moduleSymbol, isDefaultExport } = symbolOriginInfo ;
484
- return codefix . getCodeActionForImport ( moduleSymbol , {
486
+
487
+ const sourceDisplay = [ textPart ( codefix . getModuleSpecifierForNewImport ( sourceFile , moduleSymbol , compilerOptions , getCanonicalFileName , host ) ) ] ;
488
+ const codeActions = codefix . getCodeActionForImport ( moduleSymbol , {
485
489
host,
486
490
checker,
487
491
newLineCharacter : host . getNewLine ( ) ,
488
492
compilerOptions,
489
493
sourceFile,
490
494
formatContext,
491
495
symbolName : getSymbolName ( symbol , symbolOriginInfo , compilerOptions . target ) ,
492
- getCanonicalFileName : createGetCanonicalFileName ( host . useCaseSensitiveFileNames ? host . useCaseSensitiveFileNames ( ) : false ) ,
496
+ getCanonicalFileName,
493
497
symbolToken : undefined ,
494
498
kind : isDefaultExport ? codefix . ImportKind . Default : codefix . ImportKind . Named ,
495
499
} ) ;
500
+ return { sourceDisplay, codeActions } ;
496
501
}
497
502
498
503
export function getCompletionEntrySymbol (
0 commit comments