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

Method objectOwnerPath

src/extraction/tree-sitter.ts:3532–3546  ·  view source on GitHub ↗

* The links of an assignment target written as plain names — `dw_page` → * `['dw_page']`, `window.App` → `['window', 'App']`, `App.utils.dom` → * `['App', 'utils', 'dom']` — or null for anything else: `this.x`, a * computed `a[k]`, a call, CommonJS's `module.exports` / `exports.x`, or a

(left: SyntaxNode | null)

Source from the content-addressed store, hash-verified

3530 * prototype.
3531 */
3532 private objectOwnerPath(left: SyntaxNode | null): string[] | null {
3533 const path: string[] = [];
3534 let cur = left;
3535 while (cur?.type === 'member_expression') {
3536 const property = getChildByField(cur, 'property');
3537 if (property?.type !== 'property_identifier') return null;
3538 path.unshift(getNodeText(property, this.source));
3539 cur = getChildByField(cur, 'object');
3540 }
3541 if (cur?.type !== 'identifier') return null;
3542 const root = getNodeText(cur, this.source);
3543 if (root === 'module' || root === 'exports' || path.includes('prototype')) return null;
3544 path.unshift(root);
3545 return path;
3546 }
3547
3548 /**
3549 * Extract function-valued properties of an object literal as named function

Callers 1

Calls 2

getChildByFieldFunction · 0.90
getNodeTextFunction · 0.90

Tested by

no test coverage detected