MCPcopy Create free account
hub / github.com/nodejs/node / searchForNamedImport

Function searchForNamedImport

test/fixtures/snapshot/typescript.js:136460–136487  ·  view source on GitHub ↗
(namedBindings)

Source from the content-addressed store, hash-verified

136458 }
136459 }
136460 function searchForNamedImport(namedBindings) {
136461 if (!namedBindings) {
136462 return;
136463 }
136464 for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
136465 var element = _a[_i];
136466 var name = element.name, propertyName = element.propertyName;
136467 if (!isNameMatch((propertyName || name).escapedText)) {
136468 continue;
136469 }
136470 if (propertyName) {
136471 // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference.
136472 singleReferences.push(propertyName);
136473 // If renaming `{ foo as bar }`, don't touch `bar`, just `foo`.
136474 // But do rename `foo` in ` { default as foo }` if that's the original export name.
136475 if (!isForRename || name.escapedText === exportSymbol.escapedName) {
136476 // Search locally for `bar`.
136477 addSearch(name, checker.getSymbolAtLocation(name));
136478 }
136479 }
136480 else {
136481 var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName
136482 ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol.
136483 : checker.getSymbolAtLocation(name);
136484 addSearch(name, localSymbol);
136485 }
136486 }
136487 }
136488 function isNameMatch(name) {
136489 // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports
136490 return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */;

Callers 1

handleImportFunction · 0.85

Calls 3

isNameMatchFunction · 0.85
addSearchFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected