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:
@@ -459,6 +459,7 @@ test().catch(console.error);
|
|||||||
| Svelte template function calls invisible (e.g. `class={cn(...)}`) | SvelteExtractor only parsed `<script>` blocks, missing calls in template markup | `src/extraction/svelte-extractor.ts: extractTemplateCalls` scans `{expression}` blocks in template for call patterns |
|
| Svelte template function calls invisible (e.g. `class={cn(...)}`) | SvelteExtractor only parsed `<script>` blocks, missing calls in template markup | `src/extraction/svelte-extractor.ts: extractTemplateCalls` scans `{expression}` blocks in template for call patterns |
|
||||||
| Svelte `$state`/`$derived` rune calls creating noise | Runes are compiler builtins, not real function calls | `src/extraction/svelte-extractor.ts` filters `SVELTE_RUNES` set from unresolved references |
|
| Svelte `$state`/`$derived` rune calls creating noise | Runes are compiler builtins, not real function calls | `src/extraction/svelte-extractor.ts` filters `SVELTE_RUNES` set from unresolved references |
|
||||||
| Object literal getters/setters extracted as standalone functions | `method_definition` inside `object` literals treated same as class methods | `src/extraction/tree-sitter.ts: extractMethod` skips `method_definition` nodes whose parent is `object`/`object_expression` |
|
| Object literal getters/setters extracted as standalone functions | `method_definition` inside `object` literals treated same as class methods | `src/extraction/tree-sitter.ts: extractMethod` skips `method_definition` nodes whose parent is `object`/`object_expression` |
|
||||||
|
| JavaScript `class extends` produces zero inheritance edges | JS tree-sitter uses `class_heritage → identifier` (bare), not `class_heritage → extends_clause → identifier` like TypeScript | `src/extraction/tree-sitter.ts: extractInheritance` — handle bare `identifier`/`type_identifier` children when parent is `class_heritage` |
|
||||||
|
|
||||||
## After Fixing Issues
|
## After Fixing Issues
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
// Recurse into container nodes (e.g. field_declaration_list in Go structs,
|
||||||
// class_heritage in TypeScript which wraps extends_clause/implements_clause)
|
// class_heritage in TypeScript which wraps extends_clause/implements_clause)
|
||||||
if (child.type === 'field_declaration_list' || child.type === 'class_heritage') {
|
if (child.type === 'field_declaration_list' || child.type === 'class_heritage') {
|
||||||
|
|||||||
Reference in New Issue
Block a user