fix: Handle JavaScript class inheritance parsing differences from TypeScript

Addresses JavaScript `class extends` producing zero inheritance edges due to tree-sitter grammar differences. JavaScript uses `class_heritage → identifier` (bare) while TypeScript wraps with `extends_clause`. Updates extractInheritance to handle bare identifier/type_identifier children when parent is class_heritage.
This commit is contained in:
Colby McHenry
2026-04-07 13:03:47 -05:00
parent 2ae9a465ec
commit 1b279dcf94
2 changed files with 17 additions and 0 deletions
+16
View File
@@ -1688,6 +1688,22 @@ export class TreeSitterExtractor {
}
}
// JavaScript class_heritage has bare identifier without extends_clause wrapper
// e.g. `class Foo extends Bar {}` → class_heritage → identifier("Bar")
if (
(child.type === 'identifier' || child.type === 'type_identifier') &&
node.type === 'class_heritage'
) {
const name = getNodeText(child, this.source);
this.unresolvedReferences.push({
fromNodeId: classId,
referenceName: name,
referenceKind: 'extends',
line: child.startPosition.row + 1,
column: child.startPosition.column,
});
}
// Recurse into container nodes (e.g. field_declaration_list in Go structs,
// class_heritage in TypeScript which wraps extends_clause/implements_clause)
if (child.type === 'field_declaration_list' || child.type === 'class_heritage') {