CodeGraph/docs
Section 2.6.2

Inheritance & Interface Implementation

Extracting structural extends and implements relationships between classes, superclasses, and TypeScript interfaces.

Source: server/src/parser/extractors/RelationshipExtractor.ts

Class Inheritance: `extends`

For any ClassDeclaration with a superClass identifier:

server/src/parser/extractors/RelationshipExtractor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
private extractExtendsRelationship(parsedFile: ParsedFile, path: NodePath<ClassDeclaration | ClassExpression>) { const classSymbol = this.findSymbolForNode(parsedFile, path.node); if (!classSymbol || !path.node.superClass) return; if (path.node.superClass.type !== "Identifier") return; // Skip complex mixin calls const binding = path.scope.getBinding(path.node.superClass.name); if (!binding) return; const superClassSymbol = this.resolveBindingToSymbol(parsedFile, binding); if (!superClassSymbol) return; this.addRelationship({ sourceId: classSymbol.id, sourceKind: "symbol", targetId: superClassSymbol.id, targetKind: "symbol", relationshipKind: "extends" }); }

Interface Implementation: `implements`

For TypeScript implements clauses, the extractor iterates over path.node.implements and matches the interface name against parsedFile.symbols:

Implements Relationship Extraction
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
for (const impl of path.node.implements || []) { if (impl.expression.type === "Identifier") { const interfaceSymbol = parsedFile.symbols.find( s => s.name === impl.expression.name && (s.symbolKind === "interface" || s.symbolKind === "typeAlias") ); if (interfaceSymbol) { this.addRelationship({ sourceId: classSymbol.id, sourceKind: "symbol", targetId: interfaceSymbol.id, targetKind: "symbol", relationshipKind: "implements" }); } } }