(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions)
| 153676 | return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports); |
| 153677 | } |
| 153678 | function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { |
| 153679 | switch (fix.kind) { |
| 153680 | case 0 /* ImportFixKind.UseNamespace */: |
| 153681 | addNamespaceQualifier(changes, sourceFile, fix); |
| 153682 | return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; |
| 153683 | case 1 /* ImportFixKind.JsdocTypeImport */: |
| 153684 | addImportType(changes, sourceFile, fix, quotePreference); |
| 153685 | return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; |
| 153686 | case 2 /* ImportFixKind.AddToExisting */: { |
| 153687 | var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; |
| 153688 | doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); |
| 153689 | var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); |
| 153690 | return includeSymbolNameInDescription |
| 153691 | ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] |
| 153692 | : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; |
| 153693 | } |
| 153694 | case 3 /* ImportFixKind.AddNew */: { |
| 153695 | var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; |
| 153696 | var getDeclarations = useRequire ? getNewRequires : getNewImports; |
| 153697 | var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; |
| 153698 | var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; |
| 153699 | var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; |
| 153700 | ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); |
| 153701 | return includeSymbolNameInDescription |
| 153702 | ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] |
| 153703 | : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; |
| 153704 | } |
| 153705 | case 4 /* ImportFixKind.PromoteTypeOnly */: { |
| 153706 | var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; |
| 153707 | var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); |
| 153708 | return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ |
| 153709 | ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] |
| 153710 | : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; |
| 153711 | } |
| 153712 | default: |
| 153713 | return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); |
| 153714 | } |
| 153715 | } |
| 153716 | function getModuleSpecifierText(promotedDeclaration) { |
| 153717 | var _a, _b; |
| 153718 | return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ |
no test coverage detected