fix(extraction): capture top-level initializer and inline-object-method calls (#465)
The variable / method-definition extractors never walked top-level
initializer values or inline-object method bodies, so calls like
`const token = getTokenMp()` and `methods: { save() { getTokenMp() } }`
showed up nowhere in `codegraph_callers`. The variable extractor now
walks any non-object initializer value; the method-definition extractor
still skips synthetic nodes for inline-object methods (noise rationale
unchanged) but now walks their bodies for calls. Surfaces in plain
`.ts`/`.js` files as well as Vue SFCs (`<script setup>` initializers +
Options API `methods: {...}` / `setup()`), which is where the bug was
originally reported.
Closes #425.
This commit is contained in:
@@ -688,6 +688,11 @@ export class TreeSitterExtractor {
|
||||
// in inline objects). These are ephemeral and create noise (e.g., Svelte context
|
||||
// objects: `ctx.set({ get view() { ... } })`).
|
||||
if (node.parent?.type === 'object' || node.parent?.type === 'object_expression') {
|
||||
const body = this.extractor.resolveBody?.(node, this.extractor.bodyField)
|
||||
?? getChildByField(node, this.extractor.bodyField);
|
||||
if (body) {
|
||||
this.visitFunctionBody(body, '');
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Not inside a class-like node and no receiver type, treat as function
|
||||
@@ -1109,6 +1114,12 @@ export class TreeSitterExtractor {
|
||||
this.extractVariableTypeAnnotation(child, varNode.id);
|
||||
}
|
||||
|
||||
if (valueNode &&
|
||||
valueNode.type !== 'object' &&
|
||||
valueNode.type !== 'object_expression') {
|
||||
this.visitFunctionBody(valueNode, '');
|
||||
}
|
||||
|
||||
// Exported const object-of-functions: `export const actions =
|
||||
// { default: async () => {} }` (SvelteKit form actions / handler maps
|
||||
// / route tables). Extract each function-valued property as a function
|
||||
|
||||
Reference in New Issue
Block a user