Section 2.6.3Source:
server/src/parser/extractors/RelationshipExtractor.tsInstantiation Resolution
Extracting object construction via new expressions and attributing source ownership to variable declarations and function return statements.
Source:
server/src/parser/extractors/RelationshipExtractor.tsSource Attribution for `NewExpression`
When an object is instantiated with new Foo(), CodeGraph determines the appropriate source entity:
server/src/parser/extractors/RelationshipExtractor.ts
12345678910111213private resolveSourceSymbolForInstantiates(parsedFile: ParsedFile, path: NodePath<NewExpression>): ParsedSymbol | undefined { // Case 1: Assigned to a variable (e.g., const client = new RedisClient()) if (path.parentPath?.isVariableDeclarator()) { return this.findSymbolForNode(parsedFile, path.parentPath.node); } // Case 2: Returned from a function (e.g., return new UserSession()) if (path.parentPath?.isReturnStatement()) { return this.symbolStack.at(-1); // Active enclosing function/method } return undefined; // Arbitrary inline argument instantiations are skipped }
Target Class Binding
The callee must be a named identifier (e.g., new AppService()). The extractor resolves the class binding in the current file scope or across imported modules to create:
(sourceSymbol) --[instantiates]--> (classSymbol)