MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / collectImportAliases

Function collectImportAliases

scripts/migrate-schema-class.ts:200–214  ·  view source on GitHub ↗
(source: ts.SourceFile)

Source from the content-addressed store, hash-verified

198/** Collect a per-file map from local binding name → original imported name,
199 * so `import { X as Y }` resolves Y back to X for the migrated-name check. */
200const collectImportAliases = (source: ts.SourceFile): Map<string, string> => {
201 const aliases = new Map<string, string>();
202 for (const statement of source.statements) {
203 if (!ts.isImportDeclaration(statement)) continue;
204 const clause = statement.importClause;
205 if (!clause || !clause.namedBindings) continue;
206 if (!ts.isNamedImports(clause.namedBindings)) continue;
207 for (const spec of clause.namedBindings.elements) {
208 const localName = spec.name.text;
209 const importedName = spec.propertyName?.text ?? localName;
210 aliases.set(localName, importedName);
211 }
212 }
213 return aliases;
214};
215
216/** Find every `new <ClassName>(...)` call where ClassName (or its import
217 * origin) is in the migrated set. Rewrites to `<LocalName>.make(...)` so

Callers 1

Calls 1

setMethod · 0.65

Tested by

no test coverage detected