fix: INHERITS edges missing for Java extends+implements#279
Merged
DeusData merged 1 commit intoDeusData:mainfrom May 9, 2026
Merged
Conversation
Two bugs in extract_base_classes() caused most INHERITS edges to be missing for Java (and maybe other languages also): Bug 1 - Early return on first match: the field loop returned immediately on the first matching field (e.g. superclass), never processing subsequent fields (e.g. super_interfaces). Classes with both extends and implements only produced one INHERITS edge instead of multiple. Bug 2 - cbm_node_text returned full node text including keywords: calling cbm_node_text on the superclass field node returned 'extends Bar' instead of 'Bar', and on super_interfaces returned 'implements Baz, Qux' instead of the individual names. Fix: add collect_bases_from_field() which walks into child AST nodes to extract type_identifier/generic_type/qualified_name text directly, handles type_list children for multiple interfaces, and strips generic args at '<'. The field loop now collects from all matching fields before returning. Result on modelio codebase (Java): 3 -> 116 INHERITS edges.
Owner
|
Thanks @loaychlih — clean diagnosis (two distinct bugs in the same function, with a nice repro on Modelio showing 3 → 116 INHERITS edges) and a bounds-safe fix that drops in cleanly alongside the existing arena-pool pattern in this file. Verified: max writes ≤ |
DeusData
added a commit
that referenced
this pull request
May 9, 2026
…es (#279) Pins the bug-fix from #279 with a Java class declaring both extends and implements. Asserts that base_classes contains: - the superclass name (DefaultDiagramTool) - every implements interface (ILinkTool, Closeable) - bare type names only — no 'extends' / 'implements' keyword text leaking into any entry Without the fix, the field loop returned on the first match (only the extends parent emitted) and cbm_node_text on the field returned the full literal 'extends Bar' / 'implements Baz, Qux' string.
DeusData
added a commit
that referenced
this pull request
May 9, 2026
Resolved conflict in Makefile.cbm: keep both TEST_STACK_OVERFLOW_SRCS (from main, #217) and the new py_lsp test variables (TEST_SCOPE_SRCS, TEST_TYPE_REP_SRCS, TEST_PY_LSP_SRCS, TEST_PY_LSP_BENCH_SRCS, TEST_PY_LSP_STRESS_SRCS, TEST_PY_LSP_SCALE_SRCS) in ALL_TEST_SRCS. Other auto-merged files: internal/cbm/extract_defs.c (PR #279), tests/test_main.c (multiple suite registrations on each side). Brings in 28 commits from main since the branch was forked at 8fbdb0f (#207 thread safety): #208 decorator USAGE, #209 memory helpers, #210 refactor, #217 traversal stacks, #224 Svelte/Vue imports, #231 search_graph default limit, #243 path aliases, #249 GH Actions shell injection, #251 incremental destructive overwrite, #257 temporal properties, #265 Nix flake, #267-270/#289 dependabot, #273 Pine Script, #278 AUR docs, #279 INHERITS edges, #281 get_architecture wiring + follow-up, codeql revert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
extract_base_classes()ininternal/cbm/extract_defs.chad two bugsthat caused most INHERITS edges to be missing for Java (and likely other
languages using similar AST field names).
Bug 1 — Early return loses multiple inheritance targets
The field loop returned immediately on the first match:
For
class Foo extends Bar implements Baz, it foundsuperclass→ returnedimmediately → never processed
super_interfaces. Result: 1 edge instead of 2.Bug 2 — cbm_node_text returns full node text including keywords
Calling
cbm_node_texton thesuperclassfield node returned"extends Bar"instead of"Bar". Onsuper_interfacesit returned"implements Baz, Qux"instead of the individual names.Fix
Added
collect_bases_from_field()which:type_identifier/generic_type/qualified_nametext directly (skips keyword nodes likeextends/implements)type_list/interface_type_listchildren for multiple interfaces<(e.g.List<String>→List)cbm_node_textfor languages where the field IS the type nameThe field loop now collects from all matching fields before returning.
Result
Tested on Modelio
(Java codebase, 253 files):
Example edges now correctly emitted:
DefaultLinkTool→DefaultDiagramTool(extends)DefaultLinkTool→ILinkTool(implements)