Section 2.5.6Source:
server/src/parser/extractors/SymbolExtractor.tsObject Properties & Methods
Extracting key-value properties and methods declared inside object literals, handling nested objects, and avoiding pattern conflicts.
Source:
server/src/parser/extractors/SymbolExtractor.tsObject Properties vs Object Patterns
In Babel ASTs, the ObjectProperty node represents both object literal fields (const user = { name: "Alice" }) and destructuring patterns (const { name } = user).
The ObjectProperty visitor explicitly ignores destructuring patterns, which are already handled by the VariableDeclarator visitor:
server/src/parser/extractors/SymbolExtractor.ts
1234567891011121314151617181920212223242526ObjectProperty: { enter: (path: NodePath<ObjectProperty>) => { // Skip destructuring patterns (e.g., const { name } = user) if (path.parentPath?.isObjectPattern()) return; // Skip properties whose value is a function/class expression (handled by expression visitors) if ( path.node.value.type === "ArrowFunctionExpression" || path.node.value.type === "ClassExpression" || path.node.value.type === "FunctionExpression" ) return; const symbol = this.extractSymbol({ path, parsedFile, symbolKind: "objectProperty" }); // If the property value is a nested object, push symbol onto symbolStack if (symbol && path.node.value.type === "ObjectExpression") { this.symbolStack.push(symbol); path.setData("symbolPushed", true); } }, exit: (path: NodePath<ObjectProperty>) => { if (path.getData("symbolPushed")) { this.symbolStack.pop(); } } }
Nested Object Literal Hierarchy
For nested objects like const config = { db: { host: "localhost" } }:
config(variable) is pushed tosymbolStack.db(objectProperty) is extracted withparentSymbolId = config.idand pushed tosymbolStack.host(objectProperty) is extracted withparentSymbolId = db.id.- Exits pop
dbthenconfig, maintaining perfect hierarchical fidelity.