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

Function handleAppResourceTuple

src/extraction/languages/erlang.ts:267–301  ·  view source on GitHub ↗

* OTP application resource file (` .app.src` / ` .app`): a single * `{application, Name, Props}.` term the grammar parses as a top-level * expression. Two properties carry graph structure — `{mod, {Mod, _Args}}` * names the application-callback module (the app's entry point), and * `{app

(node: SyntaxNode, ctx: ExtractorContext)

Source from the content-addressed store, hash-verified

265 * out-of-repo apps stay unresolved.
266 */
267function handleAppResourceTuple(node: SyntaxNode, ctx: ExtractorContext): boolean {
268 const parentId = ctx.nodeStack[ctx.nodeStack.length - 1];
269 const props = node.namedChildren[2];
270 if (!parentId || props?.type !== 'list') return true;
271 const ref = (nameNode: SyntaxNode, kind: 'references' | 'imports'): void => {
272 const name = atomText(nameNode, ctx.source);
273 if (!name) return;
274 ctx.addUnresolvedReference({
275 fromNodeId: parentId,
276 referenceName: name,
277 referenceKind: kind,
278 line: nameNode.startPosition.row + 1,
279 column: nameNode.startPosition.column,
280 });
281 };
282 for (const prop of props.namedChildren) {
283 if (prop.type !== 'tuple' || prop.namedChildren.length < 2) continue;
284 const key = prop.namedChildren[0];
285 const value = prop.namedChildren[1];
286 if (!key || key.type !== 'atom' || !value) continue;
287 const keyName = atomText(key, ctx.source);
288 if (keyName === 'mod' && value.type === 'tuple') {
289 const mod = value.namedChildren[0];
290 if (mod?.type === 'atom') ref(mod, 'references');
291 } else if (
292 (keyName === 'applications' || keyName === 'included_applications') &&
293 value.type === 'list'
294 ) {
295 for (const app of value.namedChildren) {
296 if (app.type === 'atom') ref(app, 'imports');
297 }
298 }
299 }
300 return true; // nothing else in an app term carries graph structure
301}
302
303export const erlangExtractor: LanguageExtractor = {
304 functionTypes: ['fun_decl'], // dispatched via visitNode (name lives on the clause)

Callers 1

erlang.tsFile · 0.85

Calls 2

atomTextFunction · 0.85
refFunction · 0.70

Tested by

no test coverage detected