MCPcopy
hub / github.com/lingodotdev/lingo.dev / ImportDeclaration

Function ImportDeclaration

packages/compiler/src/utils/invokations.ts:14–38  ·  view source on GitHub ↗
(path: NodePath<t.ImportDeclaration>)

Source from the content-addressed store, hash-verified

12
13 traverse(ast, {
14 ImportDeclaration(path: NodePath<t.ImportDeclaration>) {
15 if (!params.moduleName.includes(path.node.source.value)) return;
16
17 const importNames = new Map<string, boolean | string>();
18 const specifiers = path.node.specifiers;
19
20 specifiers.forEach((specifier: t.ImportSpecifier | t.ImportDefaultSpecifier | t.ImportNamespaceSpecifier) => {
21 if (
22 t.isImportSpecifier(specifier) &&
23 t.isIdentifier(specifier.imported) &&
24 specifier.imported.name === params.functionName
25 ) {
26 importNames.set(specifier.local.name, true);
27 } else if (
28 t.isImportDefaultSpecifier(specifier) &&
29 params.functionName === "default"
30 ) {
31 importNames.set(specifier.local.name, true);
32 } else if (t.isImportNamespaceSpecifier(specifier)) {
33 importNames.set(specifier.local.name, "namespace");
34 }
35 });
36
37 collectCallExpressions(path, importNames, result, params.functionName);
38 },
39 });
40
41 return result;

Callers

nothing calls this directly

Calls 2

collectCallExpressionsFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected