fix(java-enum): resolve enum methods from enum_body_declarations - #984
fix(java-enum): resolve enum methods from enum_body_declarations#984sahil-mangla wants to merge 1 commit into
Conversation
|
Thanks. I have triaged this as a 0.9.1-rc Java extraction bug fix. Review should verify that enum_body_declarations handling fixes enum methods without changing normal class/interface method extraction or introducing duplicate method definitions. |
|
Thanks for splitting this out of #893 so quickly — exactly the atomic shape we asked for, and the |
|
Thanks for this, @sahil-mangla — the Java enum-method extraction fix is genuinely good work, and the One blocker before it can land: the PR also carries an undocumented change to the call-resolution core — Could you split this into two PRs?
Really appreciate the contribution — just want each change reviewable on its own merits. |
41f4196 to
3d6a29c
Compare
Signed-off-by: sahil-mangla <manglasahil2017@gmail.com>
3d6a29c to
4c01d66
Compare
|
Thanks, the requested split is clear and no further contributor action is needed on #984 right now. We will handle the enum-only change through a separate exact-head review of the current diff, commits, and CI before making any merge decision. The registry-resolution work remains isolated in #1128 as requested. |
|
Thank you for splitting this out to be enum-only after the earlier review — that was the right call and it made this a much cleaner thing to reason about. The core of it is correct, and I want to be precise about what I verified before getting to the three things that need changing. What is right, and verified against the vendored grammar. Genuinely nice detail: adding Three things to fix, and one of them matters a lot. 1. Enums that declare methods now lose their constants.
The fix that keeps everything working: leave Please also add This is the same defect as the one in your #1128. The review there found 2. Nested types inside an enum body are no longer walked.
3. Please gate the
While you are in there: the One thing to name rather than fix. Methods on individual enum constants with a class body — the anonymous-subclass idiom — are not extracted either before or after this change. But there is a subtle regression: on Small non-blocking tidy: the None of this is a rejection — the diagnosis is right, the label-precision instinct is right, and the double-extraction awareness is better than most contributions in this area get. Fix the constants regression and gate the routing change and this is a clear merge. |
What does this PR do?
Resolves extraction and calling-edge issues for Java enums that define methods (e.g.,
isWeekendorlabelincp_enum_method_java).In tree-sitter-java, an enum's methods are declared within an
enum_body_declarationsblock, which is a nested child ofenum_bodyrather than a direct child of the enum declaration itself. Previously:find_class_bodyresolved only the rawenum_bodynode.extract_class_methodsiterated over this body, encountering constants and separator tokens, but missing the nestedenum_body_declarationsblock. As a result, method definitions were ignored and calling edges failed to resolve.This change:
find_class_bodyto correctly scan and inspect theenum_bodyfor nestedenum_body_declarationsnodes and return them.enum_bodyandenum_body_declarationsto the list of recognized body containers inpush_class_body_childrenso the AST traverser pushes all method declarations under the correct enum QN namespace.extract_defs.c.Checklist
git commit -s) — required, CI rejects unsigned commits (DCO, see CONTRIBUTING.md)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)