MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / moduleExports

Function moduleExports

src/extraction/languages/erlang.ts:53–79  ·  view source on GitHub ↗
(node: SyntaxNode, source: string, filePath: string)

Source from the content-addressed store, hash-verified

51let lastFnId = '';
52
53function moduleExports(node: SyntaxNode, source: string, filePath: string): Set<string> | 'all' {
54 if (filePath === exportsFile) return exportsMemo;
55 let root: SyntaxNode = node;
56 while (root.parent) root = root.parent;
57 let result: Set<string> | 'all' = new Set<string>();
58 for (let i = 0; i < root.namedChildCount; i++) {
59 const form = root.namedChild(i);
60 if (!form) continue;
61 if (
62 form.type === 'compile_options_attribute' &&
63 getNodeText(form, source).includes('export_all')
64 ) {
65 result = 'all';
66 break;
67 }
68 if (form.type === 'export_attribute') {
69 for (const fa of form.namedChildren) {
70 if (fa.type !== 'fa') continue;
71 const fun = getChildByField(fa, 'fun');
72 if (fun) result.add(atomText(fun, source));
73 }
74 }
75 }
76 exportsFile = filePath;
77 exportsMemo = result;
78 return result;
79}
80
81/** The -spec directly above a function (comments may sit between), if it names it. */
82function precedingSpec(node: SyntaxNode, name: string, source: string): SyntaxNode | null {

Callers 1

handleFunDeclFunction · 0.85

Calls 3

getNodeTextFunction · 0.90
getChildByFieldFunction · 0.90
atomTextFunction · 0.85

Tested by

no test coverage detected