@tslite/services 0.0.0-stage → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/NOTICE +13 -0
- package/dist/_namespaces/edit.d.ts +8 -0
- package/dist/_namespaces/edit.js +11 -0
- package/dist/_namespaces/ts.Completions.StringCompletions.d.ts +1 -0
- package/dist/_namespaces/ts.Completions.StringCompletions.js +2 -0
- package/dist/_namespaces/ts.Completions.d.ts +2 -0
- package/dist/_namespaces/ts.Completions.js +3 -0
- package/dist/_namespaces/ts.FindAllReferences.d.ts +2 -0
- package/dist/_namespaces/ts.FindAllReferences.js +3 -0
- package/dist/_namespaces/ts.GoToDefinition.d.ts +1 -0
- package/dist/_namespaces/ts.GoToDefinition.js +2 -0
- package/dist/_namespaces/ts.NavigationBar.d.ts +1 -0
- package/dist/_namespaces/ts.NavigationBar.js +2 -0
- package/dist/_namespaces/ts.OrganizeImports.d.ts +1 -0
- package/dist/_namespaces/ts.OrganizeImports.js +2 -0
- package/dist/_namespaces/ts.OutliningElementsCollector.d.ts +1 -0
- package/dist/_namespaces/ts.OutliningElementsCollector.js +2 -0
- package/dist/_namespaces/ts.Rename.d.ts +1 -0
- package/dist/_namespaces/ts.Rename.js +2 -0
- package/dist/_namespaces/ts.SignatureHelp.d.ts +1 -0
- package/dist/_namespaces/ts.SignatureHelp.js +2 -0
- package/dist/_namespaces/ts.SmartSelectionRange.d.ts +1 -0
- package/dist/_namespaces/ts.SmartSelectionRange.js +2 -0
- package/dist/_namespaces/ts.SymbolDisplay.d.ts +1 -0
- package/dist/_namespaces/ts.SymbolDisplay.js +2 -0
- package/dist/_namespaces/ts.codefix.d.ts +26 -0
- package/dist/_namespaces/ts.codefix.js +27 -0
- package/dist/_namespaces/ts.d.ts +17 -0
- package/dist/_namespaces/ts.formatting.d.ts +7 -0
- package/dist/_namespaces/ts.formatting.js +8 -0
- package/dist/_namespaces/ts.js +20 -0
- package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.js +2 -0
- package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.js +2 -0
- package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.js +2 -0
- package/dist/_namespaces/ts.refactor.d.ts +9 -0
- package/dist/_namespaces/ts.refactor.extractSymbol.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.extractSymbol.js +2 -0
- package/dist/_namespaces/ts.refactor.js +10 -0
- package/dist/_namespaces/ts.textChanges.d.ts +1 -0
- package/dist/_namespaces/ts.textChanges.js +2 -0
- package/dist/classifier.d.ts +5 -0
- package/dist/classifier.js +439 -0
- package/dist/codeFixProvider.d.ts +13 -0
- package/dist/codeFixProvider.js +84 -0
- package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +1 -0
- package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.js +21 -0
- package/dist/codefixes/addEmptyExportDeclaration.d.ts +1 -0
- package/dist/codefixes/addEmptyExportDeclaration.js +17 -0
- package/dist/codefixes/addMissingAsync.d.ts +1 -0
- package/dist/codefixes/addMissingAsync.js +75 -0
- package/dist/codefixes/addMissingAwait.d.ts +1 -0
- package/dist/codefixes/addMissingAwait.js +236 -0
- package/dist/codefixes/addMissingConst.d.ts +1 -0
- package/dist/codefixes/addMissingConst.js +91 -0
- package/dist/codefixes/addNameToNamelessParameter.d.ts +1 -0
- package/dist/codefixes/addNameToNamelessParameter.js +29 -0
- package/dist/codefixes/convertConstToLet.d.ts +1 -0
- package/dist/codefixes/convertConstToLet.js +30 -0
- package/dist/codefixes/convertToAsyncFunction.d.ts +1 -0
- package/dist/codefixes/convertToAsyncFunction.js +495 -0
- package/dist/codefixes/convertToMappedObjectType.d.ts +1 -0
- package/dist/codefixes/convertToMappedObjectType.js +48 -0
- package/dist/codefixes/correctQualifiedNameToIndexedAccessType.d.ts +1 -0
- package/dist/codefixes/correctQualifiedNameToIndexedAccessType.js +33 -0
- package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.d.ts +1 -0
- package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.js +27 -0
- package/dist/codefixes/fixAwaitInSyncFunction.d.ts +1 -0
- package/dist/codefixes/fixAwaitInSyncFunction.js +69 -0
- package/dist/codefixes/fixExpectedComma.d.ts +1 -0
- package/dist/codefixes/fixExpectedComma.js +35 -0
- package/dist/codefixes/fixInvalidJsxCharacters.d.ts +1 -0
- package/dist/codefixes/fixInvalidJsxCharacters.js +41 -0
- package/dist/codefixes/fixMissingCallParentheses.d.ts +1 -0
- package/dist/codefixes/fixMissingCallParentheses.js +42 -0
- package/dist/codefixes/fixSpelling.d.ts +1 -0
- package/dist/codefixes/fixSpelling.js +94 -0
- package/dist/codefixes/fixUnreachableCode.d.ts +1 -0
- package/dist/codefixes/fixUnreachableCode.js +65 -0
- package/dist/codefixes/fixUnusedIdentifier.d.ts +1 -0
- package/dist/codefixes/fixUnusedIdentifier.js +224 -0
- package/dist/codefixes/helpers.d.ts +8 -0
- package/dist/codefixes/helpers.js +53 -0
- package/dist/codefixes/importFixes.d.ts +14 -0
- package/dist/codefixes/importFixes.js +441 -0
- package/dist/codefixes/inferFromUsage.d.ts +1 -0
- package/dist/codefixes/inferFromUsage.js +742 -0
- package/dist/codefixes/removeUnnecessaryAwait.d.ts +1 -0
- package/dist/codefixes/removeUnnecessaryAwait.js +41 -0
- package/dist/codefixes/returnValueCorrect.d.ts +1 -0
- package/dist/codefixes/returnValueCorrect.js +132 -0
- package/dist/codefixes/splitTypeOnlyImport.d.ts +1 -0
- package/dist/codefixes/splitTypeOnlyImport.js +32 -0
- package/dist/codefixes/useBigintLiteral.d.ts +1 -0
- package/dist/codefixes/useBigintLiteral.js +29 -0
- package/dist/completions.d.ts +83 -0
- package/dist/completions.js +1720 -0
- package/dist/documentHighlights.d.ts +8 -0
- package/dist/documentHighlights.js +367 -0
- package/dist/documentRegistry.d.ts +36 -0
- package/dist/documentRegistry.js +63 -0
- package/dist/editingServices.d.ts +1 -0
- package/dist/editingServices.js +4 -0
- package/dist/findAllReferences.d.ts +113 -0
- package/dist/findAllReferences.js +1366 -0
- package/dist/formatting/formatting.d.ts +26 -0
- package/dist/formatting/formatting.js +1021 -0
- package/dist/formatting/formattingContext.d.ts +34 -0
- package/dist/formatting/formattingContext.js +78 -0
- package/dist/formatting/formattingScanner.d.ts +14 -0
- package/dist/formatting/formattingScanner.js +228 -0
- package/dist/formatting/rule.d.ts +31 -0
- package/dist/formatting/rule.js +22 -0
- package/dist/formatting/rules.d.ts +7 -0
- package/dist/formatting/rules.js +610 -0
- package/dist/formatting/rulesMap.d.ts +5 -0
- package/dist/formatting/rulesMap.js +127 -0
- package/dist/formatting/smartIndenter.d.ts +44 -0
- package/dist/formatting/smartIndenter.js +518 -0
- package/dist/getEditsForFileRename.d.ts +6 -0
- package/dist/getEditsForFileRename.js +86 -0
- package/dist/goToDefinition.d.ts +8 -0
- package/dist/goToDefinition.js +246 -0
- package/dist/importTracker.d.ts +50 -0
- package/dist/importTracker.js +422 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/navigationBar.d.ts +3 -0
- package/dist/navigationBar.js +549 -0
- package/dist/organizeImports.d.ts +18 -0
- package/dist/organizeImports.js +290 -0
- package/dist/outliningElementsCollector.d.ts +2 -0
- package/dist/outliningElementsCollector.js +261 -0
- package/dist/refactorProvider.d.ts +5 -0
- package/dist/refactorProvider.js +16 -0
- package/dist/refactors/addOrRemoveBracesToArrowFunction.d.ts +1 -0
- package/dist/refactors/addOrRemoveBracesToArrowFunction.js +86 -0
- package/dist/refactors/convertExport.d.ts +1 -0
- package/dist/refactors/convertExport.js +126 -0
- package/dist/refactors/convertImport.d.ts +1 -0
- package/dist/refactors/convertImport.js +116 -0
- package/dist/refactors/convertParamsToDestructuredObject.d.ts +1 -0
- package/dist/refactors/convertParamsToDestructuredObject.js +282 -0
- package/dist/refactors/convertStringOrTemplateLiteral.d.ts +1 -0
- package/dist/refactors/convertStringOrTemplateLiteral.js +148 -0
- package/dist/refactors/extractSymbol.d.ts +60 -0
- package/dist/refactors/extractSymbol.js +1281 -0
- package/dist/refactors/extractType.d.ts +1 -0
- package/dist/refactors/extractType.js +102 -0
- package/dist/refactors/moveToNewFile.d.ts +1 -0
- package/dist/refactors/moveToNewFile.js +477 -0
- package/dist/rename.d.ts +2 -0
- package/dist/rename.js +100 -0
- package/dist/services.d.ts +48 -0
- package/dist/services.js +1480 -0
- package/dist/signatureHelp.d.ts +8 -0
- package/dist/signatureHelp.js +414 -0
- package/dist/smartSelection.d.ts +2 -0
- package/dist/smartSelection.js +243 -0
- package/dist/stringCompletions.d.ts +4 -0
- package/dist/stringCompletions.js +220 -0
- package/dist/suggestionDiagnostics.d.ts +6 -0
- package/dist/suggestionDiagnostics.js +92 -0
- package/dist/symbolDisplay.d.ts +16 -0
- package/dist/symbolDisplay.js +400 -0
- package/dist/textChanges.d.ts +161 -0
- package/dist/textChanges.js +1163 -0
- package/dist/types.d.ts +908 -0
- package/dist/types.js +263 -0
- package/dist/utilities.d.ts +283 -0
- package/dist/utilities.js +1981 -0
- package/package.json +45 -3
- package/README.md +0 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { formatting, textChanges } from "../_namespaces/edit.js";
|
|
2
|
+
import type { CheckResult, CodeAction, CodeFixContextBase, DiagnosticWithLocation, LanguageServiceHost, SourceFile, Symbol, UserPreferences } from "../_namespaces/edit.js";
|
|
3
|
+
export declare const importFixName = "import";
|
|
4
|
+
export interface ImportAdder {
|
|
5
|
+
addImportFromDiagnostic: (diagnostic: DiagnosticWithLocation, context: CodeFixContextBase) => void;
|
|
6
|
+
addImportFromExportedSymbol: (exportedSymbol: Symbol, usageIsTypeOnly?: boolean) => void;
|
|
7
|
+
writeFixes: (changeTracker: textChanges.ChangeTracker) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function createImportAdder(sourceFile: SourceFile, program: CheckResult, preferences: UserPreferences, host: LanguageServiceHost): ImportAdder;
|
|
10
|
+
export declare function getImportCompletionAction(exportedSymbol: Symbol, moduleSymbol: Symbol, sourceFile: SourceFile, symbolName: string, host: LanguageServiceHost, program: CheckResult, formatContext: formatting.FormatContext, position: number, preferences: UserPreferences): {
|
|
11
|
+
readonly moduleSpecifier: string;
|
|
12
|
+
readonly codeAction: CodeAction;
|
|
13
|
+
};
|
|
14
|
+
export declare function forEachExternalModuleToImportFrom(program: CheckResult, _host: LanguageServiceHost, from: SourceFile, cb: (module: Symbol) => void): void;
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
// Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/importFixes.ts: o namespace virou módulo ES, com os imports explícitos.
|
|
2
|
+
import { Completions, Debug, Diagnostics, InternalSymbolName, ScriptTarget, SymbolFlags, SyntaxKind, arrayFrom, cast, combine, createIdentifier, createImportSpecifier, createMap, createModuleSpecifierResolutionHost, createMultiMap, createNamedImports, emptyArray, escapeLeadingUnderscores, first, firstDefined, flatMap, flatMapIterator, formatting, getDirectoryPath, getMeaningFromDeclaration, getMeaningFromLocation, getNameForExportedSymbol, getNodeId, getQuotePreference, getTokenAtPosition, getTypeKeywordOfTypeOnlyImport, getUniqueSymbolId, importFromModuleSpecifier, insertImports, isExportAssignment, isExportSpecifier, isExternalOrCommonJsModule, isIdentifier, isNamedImports, isNamespaceImport, isStringLiteral, isValidTypeOnlyAliasUseSite, last, makeImport, mapDefined, moduleSymbolToValidIdentifier, moduleSpecifiers, pushIfUnique, skipAlias, some, sort, startsWith, stripQuotes, textChanges, tryCast, } from "../_namespaces/edit.js";
|
|
3
|
+
import { createCodeFixAction, createCombinedCodeActions, eachDiagnostic, registerCodeFix, } from "../_namespaces/ts.codefix.js";
|
|
4
|
+
export const importFixName = "import";
|
|
5
|
+
const importFixId = "fixMissingImport";
|
|
6
|
+
// Na tag, também o nome que seria um membro do `this` ou um membro estático (CK-02), e o global de um UMD num módulo
|
|
7
|
+
// (CK-03): a cópia não acusa esses erros.
|
|
8
|
+
const errorCodes = [
|
|
9
|
+
Diagnostics.Cannot_find_name_0.code,
|
|
10
|
+
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
11
|
+
Diagnostics.Cannot_find_namespace_0.code,
|
|
12
|
+
Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
|
|
13
|
+
];
|
|
14
|
+
// O alvo da configuração fixa (CK-24): o do nome que se importa.
|
|
15
|
+
const languageVersion = ScriptTarget.ES2020;
|
|
16
|
+
registerCodeFix({
|
|
17
|
+
errorCodes,
|
|
18
|
+
getCodeActions(context) {
|
|
19
|
+
const { preferences, sourceFile, span } = context;
|
|
20
|
+
const info = getFixesInfo(context, span.start);
|
|
21
|
+
if (!info)
|
|
22
|
+
return undefined;
|
|
23
|
+
const { fixes, symbolName } = info;
|
|
24
|
+
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
25
|
+
return fixes.map(fix => codeActionForFix(context, sourceFile, symbolName, fix, quotePreference));
|
|
26
|
+
},
|
|
27
|
+
fixIds: [importFixId],
|
|
28
|
+
getAllCodeActions: context => {
|
|
29
|
+
const { sourceFile, program, preferences, host } = context;
|
|
30
|
+
const importAdder = createImportAdder(sourceFile, program, preferences, host);
|
|
31
|
+
eachDiagnostic(context, errorCodes, diag => importAdder.addImportFromDiagnostic(diag, context));
|
|
32
|
+
return createCombinedCodeActions(textChanges.ChangeTracker.with(context, importAdder.writeFixes));
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export function createImportAdder(sourceFile, program, preferences, host) {
|
|
36
|
+
// Namespace fixes don't conflict, so just build a list.
|
|
37
|
+
const addToNamespace = [];
|
|
38
|
+
// Keys are import clause node IDs.
|
|
39
|
+
const addToExisting = createMap();
|
|
40
|
+
const newImports = createMap();
|
|
41
|
+
return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes };
|
|
42
|
+
function addImportFromDiagnostic(diagnostic, context) {
|
|
43
|
+
const info = getFixesInfo(context, diagnostic.start);
|
|
44
|
+
if (!info || !info.fixes.length)
|
|
45
|
+
return;
|
|
46
|
+
addImport(info);
|
|
47
|
+
}
|
|
48
|
+
// Na tag, o uso só de tipo pedia um import de tipo quando o `importsNotUsedAsValues` era `error`; a configuração
|
|
49
|
+
// fixa o deixa no padrão (CK-24).
|
|
50
|
+
function addImportFromExportedSymbol(exportedSymbol) {
|
|
51
|
+
const moduleSymbol = Debug.checkDefined(exportedSymbol.parent);
|
|
52
|
+
const symbolName = getNameForExportedSymbol(exportedSymbol, languageVersion);
|
|
53
|
+
const checker = program.getTypeChecker();
|
|
54
|
+
const symbol = checker.getMergedSymbol(skipAlias(exportedSymbol, checker));
|
|
55
|
+
const exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, checker, program.getSourceFiles());
|
|
56
|
+
const fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, host, preferences);
|
|
57
|
+
addImport({ fixes: [fix], symbolName });
|
|
58
|
+
}
|
|
59
|
+
function addImport(info) {
|
|
60
|
+
const { fixes, symbolName } = info;
|
|
61
|
+
const fix = first(fixes);
|
|
62
|
+
switch (fix.kind) {
|
|
63
|
+
case 0 /* ImportFixKind.UseNamespace */:
|
|
64
|
+
addToNamespace.push(fix);
|
|
65
|
+
break;
|
|
66
|
+
case 1 /* ImportFixKind.AddToExisting */: {
|
|
67
|
+
const { importClauseOrBindingPattern, importKind, canUseTypeOnlyImport } = fix;
|
|
68
|
+
const key = String(getNodeId(importClauseOrBindingPattern));
|
|
69
|
+
let entry = addToExisting.get(key);
|
|
70
|
+
if (!entry) {
|
|
71
|
+
addToExisting.set(key, entry = { importClauseOrBindingPattern, defaultImport: undefined, namedImports: [], canUseTypeOnlyImport });
|
|
72
|
+
}
|
|
73
|
+
if (importKind === 0 /* ImportKind.Named */) {
|
|
74
|
+
pushIfUnique(entry.namedImports, symbolName);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName");
|
|
78
|
+
entry.defaultImport = symbolName;
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 2 /* ImportFixKind.AddNew */: {
|
|
83
|
+
const { moduleSpecifier, importKind } = fix;
|
|
84
|
+
let entry = newImports.get(moduleSpecifier);
|
|
85
|
+
if (!entry) {
|
|
86
|
+
newImports.set(moduleSpecifier, entry = { namedImports: [] });
|
|
87
|
+
}
|
|
88
|
+
switch (importKind) {
|
|
89
|
+
case 1 /* ImportKind.Default */:
|
|
90
|
+
Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName");
|
|
91
|
+
entry.defaultImport = symbolName;
|
|
92
|
+
break;
|
|
93
|
+
case 0 /* ImportKind.Named */:
|
|
94
|
+
pushIfUnique(entry.namedImports || (entry.namedImports = []), symbolName);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
default:
|
|
100
|
+
Debug.assertNever(fix, `fix wasn't never - got kind ${fix.kind}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function writeFixes(changeTracker) {
|
|
104
|
+
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
105
|
+
for (const fix of addToNamespace) {
|
|
106
|
+
addNamespaceQualifier(changeTracker, sourceFile, fix);
|
|
107
|
+
}
|
|
108
|
+
addToExisting.forEach(({ importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport }) => {
|
|
109
|
+
doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport);
|
|
110
|
+
});
|
|
111
|
+
let newDeclarations;
|
|
112
|
+
newImports.forEach((imports, moduleSpecifier) => {
|
|
113
|
+
newDeclarations = combine(newDeclarations, getNewImports(moduleSpecifier, quotePreference, imports));
|
|
114
|
+
});
|
|
115
|
+
if (newDeclarations) {
|
|
116
|
+
insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Sorted with the preferred fix coming first.
|
|
121
|
+
// Na tag, também o `import("./a").T` no lugar do nome, que só um arquivo JavaScript pedia (CK-03).
|
|
122
|
+
var ImportFixKind;
|
|
123
|
+
(function (ImportFixKind) {
|
|
124
|
+
ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace";
|
|
125
|
+
ImportFixKind[ImportFixKind["AddToExisting"] = 1] = "AddToExisting";
|
|
126
|
+
ImportFixKind[ImportFixKind["AddNew"] = 2] = "AddNew";
|
|
127
|
+
})(ImportFixKind || (ImportFixKind = {}));
|
|
128
|
+
// Na tag, também o import de namespace e o `import x = require(…)`, que só o global de um UMD e o valor de um
|
|
129
|
+
// `export =` pediam (CK-03).
|
|
130
|
+
var ImportKind;
|
|
131
|
+
(function (ImportKind) {
|
|
132
|
+
ImportKind[ImportKind["Named"] = 0] = "Named";
|
|
133
|
+
ImportKind[ImportKind["Default"] = 1] = "Default";
|
|
134
|
+
})(ImportKind || (ImportKind = {}));
|
|
135
|
+
export function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
|
|
136
|
+
const exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, program.getTypeChecker(), program.getSourceFiles());
|
|
137
|
+
const moduleSpecifier = first(getNewImportInfos(sourceFile, exportInfos, host, preferences)).moduleSpecifier;
|
|
138
|
+
const fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, host, preferences);
|
|
139
|
+
return { moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host, formatContext, preferences }, sourceFile, symbolName, fix, getQuotePreference(sourceFile, preferences))) };
|
|
140
|
+
}
|
|
141
|
+
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, host, preferences) {
|
|
142
|
+
Debug.assert(exportInfos.some(info => info.moduleSymbol === moduleSymbol), "Some exportInfo should match the specified moduleSymbol");
|
|
143
|
+
// We sort the best codefixes first, so taking `first` is best.
|
|
144
|
+
return first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences));
|
|
145
|
+
}
|
|
146
|
+
// Na tag, também os `commands` da ação (CK-47).
|
|
147
|
+
function codeFixActionToCodeAction({ description, changes }) {
|
|
148
|
+
return { description, changes };
|
|
149
|
+
}
|
|
150
|
+
function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, checker, allSourceFiles) {
|
|
151
|
+
const result = [];
|
|
152
|
+
forEachExternalModule(checker, allSourceFiles, (moduleSymbol, moduleFile) => {
|
|
153
|
+
// Don't import from a re-export when looking "up" like to `./index` or `../index`.
|
|
154
|
+
if (moduleSymbol !== exportingModuleSymbol && startsWith(importingFile.fileName, getDirectoryPath(moduleFile.fileName))) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker);
|
|
158
|
+
if (defaultInfo && defaultInfo.name === symbolName && skipAlias(defaultInfo.symbol, checker) === exportedSymbol) {
|
|
159
|
+
result.push({ moduleSymbol, importKind: defaultInfo.kind });
|
|
160
|
+
}
|
|
161
|
+
for (const exported of checker.getExportsAndPropertiesOfModule(moduleSymbol)) {
|
|
162
|
+
if (exported.name === symbolName && skipAlias(exported, checker) === exportedSymbol) {
|
|
163
|
+
result.push({ moduleSymbol, importKind: 0 /* ImportKind.Named */ });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
function isTypeOnlyPosition(sourceFile, position) {
|
|
170
|
+
return isValidTypeOnlyAliasUseSite(getTokenAtPosition(sourceFile, position));
|
|
171
|
+
}
|
|
172
|
+
function getFixForImport(exportInfos, symbolName,
|
|
173
|
+
/** undefined only for missing JSX namespace */
|
|
174
|
+
position, program, sourceFile, host, preferences) {
|
|
175
|
+
const checker = program.getTypeChecker();
|
|
176
|
+
const existingImports = flatMap(exportInfos, info => getExistingImportDeclarations(info, checker, sourceFile));
|
|
177
|
+
const useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
|
|
178
|
+
const addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position));
|
|
179
|
+
// Don't bother providing an action to add a new import if we can add to an existing one.
|
|
180
|
+
const addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, sourceFile, host, preferences);
|
|
181
|
+
return [...(useNamespace ? [useNamespace] : emptyArray), ...addImport];
|
|
182
|
+
}
|
|
183
|
+
function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) {
|
|
184
|
+
// It is possible that multiple import statements with the same specifier exist in the file.
|
|
185
|
+
// e.g.
|
|
186
|
+
//
|
|
187
|
+
// import * as ns from "foo";
|
|
188
|
+
// import { member1, member2 } from "foo";
|
|
189
|
+
//
|
|
190
|
+
// member3/**/ <-- cusor here
|
|
191
|
+
//
|
|
192
|
+
// in this case we should provie 2 actions:
|
|
193
|
+
// 1. change "member3" to "ns.member3"
|
|
194
|
+
// 2. add "member3" to the second import statement's import list
|
|
195
|
+
// and it is up to the user to decide which one fits best.
|
|
196
|
+
return firstDefined(existingImports, ({ declaration }) => {
|
|
197
|
+
const namespacePrefix = getNamespaceLikeImportText(declaration);
|
|
198
|
+
if (namespacePrefix) {
|
|
199
|
+
const moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker);
|
|
200
|
+
if (moduleSymbol && moduleSymbol.exports.has(escapeLeadingUnderscores(symbolName))) {
|
|
201
|
+
return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix, position };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// Na tag, também o `const x = require(…)` e o `import x = require(…)` (CK-03).
|
|
207
|
+
function getTargetModuleFromNamespaceLikeImport(declaration, checker) {
|
|
208
|
+
const namespaceImport = tryCast(declaration.importClause?.namedBindings, isNamespaceImport);
|
|
209
|
+
return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol);
|
|
210
|
+
}
|
|
211
|
+
// Na tag, também o `const x = require(…)` e o `import x = require(…)` (CK-03).
|
|
212
|
+
function getNamespaceLikeImportText(declaration) {
|
|
213
|
+
return tryCast(declaration.importClause?.namedBindings, isNamespaceImport)?.name.text;
|
|
214
|
+
}
|
|
215
|
+
function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) {
|
|
216
|
+
return firstDefined(existingImports, ({ declaration, importKind }) => {
|
|
217
|
+
// Na tag, o `import =` não recebia mais nada, e o padrão de um `const { … } = require(…)` recebia o nome (CK-03).
|
|
218
|
+
const { importClause } = declaration;
|
|
219
|
+
if (!importClause)
|
|
220
|
+
return undefined;
|
|
221
|
+
const { name, namedBindings } = importClause;
|
|
222
|
+
return importKind === 1 /* ImportKind.Default */ && !name || importKind === 0 /* ImportKind.Named */ && (!namedBindings || namedBindings.kind === SyntaxKind.NamedImports)
|
|
223
|
+
? { kind: 1 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport }
|
|
224
|
+
: undefined;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function getExistingImportDeclarations({ moduleSymbol, importKind }, checker, sourceFile) {
|
|
228
|
+
// Na tag, também o `const x = require(…)` e o `import x = require(…)`, e, num arquivo JavaScript, nenhum import ES
|
|
229
|
+
// para um tipo (CK-03).
|
|
230
|
+
return mapDefined(sourceFile.imports, (moduleSpecifier) => {
|
|
231
|
+
const i = importFromModuleSpecifier(moduleSpecifier);
|
|
232
|
+
if (i.kind === SyntaxKind.ImportDeclaration) {
|
|
233
|
+
return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind } : undefined;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
// Na tag, também o `import("./a").T` que um arquivo JavaScript pedia para um tipo (CK-03), e, à frente dos specifiers
|
|
238
|
+
// mais curtos, os que o `package.json` cobria (CK-47). Recebia também o programa, pelas opções e pelo host do specifier.
|
|
239
|
+
function getNewImportInfos(sourceFile, moduleSymbols, host, preferences) {
|
|
240
|
+
const choicesForEachExportingModule = flatMap(moduleSymbols, ({ moduleSymbol, importKind }) => moduleSpecifiers.getModuleSpecifiers(moduleSymbol, sourceFile, createModuleSpecifierResolutionHost(host), preferences)
|
|
241
|
+
.map((moduleSpecifier) => ({ kind: 2 /* ImportFixKind.AddNew */, moduleSpecifier, importKind })));
|
|
242
|
+
// Shortest paths first
|
|
243
|
+
return sort(choicesForEachExportingModule, (a, b) => a.moduleSpecifier.length - b.moduleSpecifier.length);
|
|
244
|
+
}
|
|
245
|
+
// Na tag, recebia também o programa, que só repassava.
|
|
246
|
+
function getFixesForAddImport(exportInfos, existingImports, sourceFile, host, preferences) {
|
|
247
|
+
const existingDeclaration = firstDefined(existingImports, info => newImportInfoFromExistingSpecifier(info));
|
|
248
|
+
return existingDeclaration ? [existingDeclaration] : getNewImportInfos(sourceFile, exportInfos, host, preferences);
|
|
249
|
+
}
|
|
250
|
+
// Na tag, também o specifier de um `const x = require(…)` e de um `import x = require(…)` (CK-03).
|
|
251
|
+
function newImportInfoFromExistingSpecifier({ declaration, importKind }) {
|
|
252
|
+
const moduleSpecifier = declaration.moduleSpecifier;
|
|
253
|
+
return isStringLiteral(moduleSpecifier)
|
|
254
|
+
? { kind: 2 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier.text, importKind }
|
|
255
|
+
: undefined;
|
|
256
|
+
}
|
|
257
|
+
// Na tag, recebia também o código do erro, e o do global de um UMD num módulo ia ao import do UMD (CK-03).
|
|
258
|
+
function getFixesInfo(context, pos) {
|
|
259
|
+
const symbolToken = getTokenAtPosition(context.sourceFile, pos);
|
|
260
|
+
const info = isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken) : undefined;
|
|
261
|
+
return info && { ...info, fixes: sort(info.fixes, (a, b) => a.kind - b.kind) };
|
|
262
|
+
}
|
|
263
|
+
function getFixesInfoForNonUMDImport({ sourceFile, program, cancellationToken, host, preferences }, symbolToken) {
|
|
264
|
+
const checker = program.getTypeChecker();
|
|
265
|
+
// Na tag, a tag de um elemento JSX que já estava em escopo pedia o import da fábrica do JSX (o `React`), que é do
|
|
266
|
+
// emit (CK-19).
|
|
267
|
+
const symbolName = symbolToken.text;
|
|
268
|
+
// "default" is a keyword and not a legal identifier for the import, so we don't expect it here
|
|
269
|
+
Debug.assert(symbolName !== InternalSymbolName.Default, "'default' isn't a legal identifier and couldn't occur here");
|
|
270
|
+
const exportInfos = getExportInfos(symbolName, getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host);
|
|
271
|
+
const fixes = arrayFrom(flatMapIterator(exportInfos.entries(), ([_, exportInfos]) => getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences)));
|
|
272
|
+
return { fixes, symbolName };
|
|
273
|
+
}
|
|
274
|
+
// Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
|
|
275
|
+
function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) {
|
|
276
|
+
// For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
|
|
277
|
+
// Maps symbol id to info for modules providing that symbol (original export + re-exports).
|
|
278
|
+
const originalSymbolToExportInfos = createMultiMap();
|
|
279
|
+
function addSymbol(moduleSymbol, exportedSymbol, importKind) {
|
|
280
|
+
originalSymbolToExportInfos.add(getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol, importKind });
|
|
281
|
+
}
|
|
282
|
+
forEachExternalModuleToImportFrom(program, host, sourceFile, moduleSymbol => {
|
|
283
|
+
cancellationToken.throwIfCancellationRequested();
|
|
284
|
+
const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker);
|
|
285
|
+
if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
286
|
+
addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind);
|
|
287
|
+
}
|
|
288
|
+
// check exports with the same name
|
|
289
|
+
const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol);
|
|
290
|
+
if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
|
|
291
|
+
addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* ImportKind.Named */);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
return originalSymbolToExportInfos;
|
|
295
|
+
}
|
|
296
|
+
// Na tag, recebia também o arquivo que importa e as opções, que decidiam o import do valor de um `export =` (CK-03).
|
|
297
|
+
function getDefaultLikeExportInfo(moduleSymbol, checker) {
|
|
298
|
+
const exported = getDefaultLikeExportWorker(moduleSymbol, checker);
|
|
299
|
+
if (!exported)
|
|
300
|
+
return undefined;
|
|
301
|
+
const { symbol, kind } = exported;
|
|
302
|
+
const info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker);
|
|
303
|
+
return info && { symbol, kind, ...info };
|
|
304
|
+
}
|
|
305
|
+
// Na tag, também o valor do `export =` do módulo, importado como default, como namespace ou pelo `import =` (CK-03).
|
|
306
|
+
function getDefaultLikeExportWorker(moduleSymbol, checker) {
|
|
307
|
+
const defaultExport = checker.tryGetMemberInModuleExports(InternalSymbolName.Default, moduleSymbol);
|
|
308
|
+
if (defaultExport)
|
|
309
|
+
return { symbol: defaultExport, kind: 1 /* ImportKind.Default */ };
|
|
310
|
+
return undefined;
|
|
311
|
+
}
|
|
312
|
+
// Na tag, primeiro o símbolo local de uma declaração com o modificador `default`, que só vinha diante da `function` e da
|
|
313
|
+
// classe (CK-02); o `export default` que fica é de expressão, e não tem símbolo local (CK-46).
|
|
314
|
+
function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker) {
|
|
315
|
+
const name = getNameForExportDefault(defaultExport);
|
|
316
|
+
if (name !== undefined)
|
|
317
|
+
return { symbolForMeaning: defaultExport, name };
|
|
318
|
+
if (defaultExport.flags & SymbolFlags.Alias) {
|
|
319
|
+
const aliased = checker.getImmediateAliasedSymbol(defaultExport);
|
|
320
|
+
return aliased && getDefaultExportInfoWorker(aliased, Debug.checkDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker);
|
|
321
|
+
}
|
|
322
|
+
// Na tag, também o nome `export=` (CK-03).
|
|
323
|
+
if (defaultExport.escapedName !== InternalSymbolName.Default) {
|
|
324
|
+
return { symbolForMeaning: defaultExport, name: defaultExport.getName() };
|
|
325
|
+
}
|
|
326
|
+
return { symbolForMeaning: defaultExport, name: moduleSymbolToValidIdentifier(moduleSymbol, languageVersion) };
|
|
327
|
+
}
|
|
328
|
+
function getNameForExportDefault(symbol) {
|
|
329
|
+
return symbol.declarations && firstDefined(symbol.declarations, declaration => {
|
|
330
|
+
if (isExportAssignment(declaration)) {
|
|
331
|
+
if (isIdentifier(declaration.expression)) {
|
|
332
|
+
return declaration.expression.text;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else if (isExportSpecifier(declaration)) {
|
|
336
|
+
Debug.assert(declaration.name.text === InternalSymbolName.Default, "Expected the specifier to be a default export");
|
|
337
|
+
return declaration.propertyName && declaration.propertyName.text;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) {
|
|
342
|
+
let diag;
|
|
343
|
+
const changes = textChanges.ChangeTracker.with(context, tracker => {
|
|
344
|
+
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference);
|
|
345
|
+
});
|
|
346
|
+
return createCodeFixAction(importFixName, changes, diag, importFixId, Diagnostics.Add_all_missing_imports);
|
|
347
|
+
}
|
|
348
|
+
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) {
|
|
349
|
+
switch (fix.kind) {
|
|
350
|
+
case 0 /* ImportFixKind.UseNamespace */:
|
|
351
|
+
addNamespaceQualifier(changes, sourceFile, fix);
|
|
352
|
+
return [Diagnostics.Change_0_to_1, symbolName, `${fix.namespacePrefix}.${symbolName}`];
|
|
353
|
+
case 1 /* ImportFixKind.AddToExisting */: {
|
|
354
|
+
const { importClauseOrBindingPattern, importKind, canUseTypeOnlyImport, moduleSpecifier } = fix;
|
|
355
|
+
doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? symbolName : undefined, importKind === 0 /* ImportKind.Named */ ? [symbolName] : emptyArray, canUseTypeOnlyImport);
|
|
356
|
+
const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier);
|
|
357
|
+
return [importKind === 1 /* ImportKind.Default */ ? Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; // you too!
|
|
358
|
+
}
|
|
359
|
+
case 2 /* ImportFixKind.AddNew */: {
|
|
360
|
+
const { importKind, moduleSpecifier } = fix;
|
|
361
|
+
const importsCollection = importKind === 1 /* ImportKind.Default */ ? { defaultImport: symbolName } : { namedImports: [symbolName] };
|
|
362
|
+
insertImports(changes, sourceFile, getNewImports(moduleSpecifier, quotePreference, importsCollection), /*blankLineBetween*/ true);
|
|
363
|
+
return [importKind === 1 /* ImportKind.Default */ ? Diagnostics.Import_default_0_from_module_1 : Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
|
|
364
|
+
}
|
|
365
|
+
default:
|
|
366
|
+
return Debug.assertNever(fix, `Unexpected fix kind ${fix.kind}`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// Na tag, o import existente podia ser também o padrão de um `const { … } = require(…)`, que recebia os nomes (CK-03).
|
|
370
|
+
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) {
|
|
371
|
+
const convertTypeOnlyToRegular = !canUseTypeOnlyImport && clause.isTypeOnly;
|
|
372
|
+
if (defaultImport) {
|
|
373
|
+
Debug.assert(!clause.name, "Cannot add a default import to an import clause that already has one");
|
|
374
|
+
changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), createIdentifier(defaultImport), { suffix: ", " });
|
|
375
|
+
}
|
|
376
|
+
if (namedImports.length) {
|
|
377
|
+
const specifiers = namedImports.map(name => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)));
|
|
378
|
+
if (clause.namedBindings && cast(clause.namedBindings, isNamedImports).elements.length) {
|
|
379
|
+
for (const spec of specifiers) {
|
|
380
|
+
changes.insertNodeInListAfter(sourceFile, last(cast(clause.namedBindings, isNamedImports).elements), spec);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
if (specifiers.length) {
|
|
385
|
+
const namedImports = createNamedImports(specifiers);
|
|
386
|
+
if (clause.namedBindings) {
|
|
387
|
+
changes.replaceNode(sourceFile, clause.namedBindings, namedImports);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
changes.insertNodeAfter(sourceFile, Debug.checkDefined(clause.name, "Import clause must have either named imports or a default import"), namedImports);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (convertTypeOnlyToRegular) {
|
|
396
|
+
changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(clause, sourceFile));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function addNamespaceQualifier(changes, sourceFile, { namespacePrefix, position }) {
|
|
400
|
+
changes.insertText(sourceFile, position, namespacePrefix + ".");
|
|
401
|
+
}
|
|
402
|
+
// Na tag, também o `import * as ns` e o `import x = require(…)` (CK-03).
|
|
403
|
+
function getNewImports(moduleSpecifier, quotePreference, imports) {
|
|
404
|
+
let statements;
|
|
405
|
+
if (imports.defaultImport !== undefined || imports.namedImports?.length) {
|
|
406
|
+
statements = combine(statements, makeImport(imports.defaultImport === undefined ? undefined : createIdentifier(imports.defaultImport), imports.namedImports?.map(n => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(n))), moduleSpecifier, quotePreference));
|
|
407
|
+
}
|
|
408
|
+
return Debug.checkDefined(statements);
|
|
409
|
+
}
|
|
410
|
+
// Na tag, também o `getNewRequires` e o `createConstEqualsRequireDeclaration`, que escreviam o `const x = require(…)`
|
|
411
|
+
// de um arquivo JavaScript (CK-03).
|
|
412
|
+
function symbolHasMeaning({ declarations }, meaning) {
|
|
413
|
+
return some(declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning));
|
|
414
|
+
}
|
|
415
|
+
// Na tag, também se o filtro dos módulos pelo `package.json` valia; o filtro, o arquivo de dentro de um `node_modules`
|
|
416
|
+
// que um import não alcançava, o symlink e o registro do que o filtro tirava eram do host (CK-46, CK-47). O nome de um
|
|
417
|
+
// arquivo é uma chave virtual, e todo módulo do programa se importa.
|
|
418
|
+
export function forEachExternalModuleToImportFrom(program, _host, from, cb) {
|
|
419
|
+
forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), (module, sourceFile) => {
|
|
420
|
+
if (sourceFile !== from) {
|
|
421
|
+
cb(module);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
// Na tag, também os módulos ambientes, de um `declare module "x"` (CK-02, princípio 4).
|
|
426
|
+
function forEachExternalModule(checker, allSourceFiles, cb) {
|
|
427
|
+
for (const sourceFile of allSourceFiles) {
|
|
428
|
+
if (isExternalOrCommonJsModule(sourceFile)) {
|
|
429
|
+
cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
// Na tag, aqui vinham o `isImportableFile` e o `isImportablePath`, do `node_modules` e do symlink, e o
|
|
434
|
+
// `createAutoImportFilter`, do `package.json` (CK-46, CK-47). O `moduleSymbolToValidIdentifier` e o
|
|
435
|
+
// `moduleSpecifierToValidIdentifier` desceram para o `utilities.ts` da leitura, que os usa sem a edição (CK-67).
|
|
436
|
+
// O auto-import do completion: a leitura o alcança por este registro, que a edição faz ao carregar (CK-67). O completion
|
|
437
|
+
// passa as opções de formatação cruas, e o contexto de formatação se monta aqui, como a casca da tag o montava.
|
|
438
|
+
Completions.registerAutoImportProvider({
|
|
439
|
+
forEachExternalModuleToImportFrom,
|
|
440
|
+
getImportCompletionAction: (exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatOptions, position, preferences) => getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, (formatOptions && formatting.getFormatContext(formatOptions, host)), position, preferences),
|
|
441
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|