Repository navigation
fix(java): give Lombok @Getter fields the getter node javac sees (#5148) - #5347
Deepjyoti-Sarmah wants to merge 3 commits into
Conversation
A chain through a Lombok-generated getter (Model.getInstance().work()) had no calls edge, because the getter has no declaration in the source. Pins the issue repro, the getter node's shape, Lombok's get/is naming, class-level @Getter skipping static fields, and the cases that must add nothing.
A field (or class) annotated with Lombok's @Getter now gets a .getX()/.isX() node with arity 0, a method edge from its class, and the field's type as its return type, so the existing Java chain typing (Graphify-Labs#4306) resolves Model.getInstance().work(). A bare @Getter counts only when the file imports lombok.Getter or lombok.*; AccessLevel.NONE and a hand-written zero-argument method of the same name (case-insensitive) suppress it.
Cached Java extractions from 0.9.112 have no getter nodes, so they must re-run.
|
Thanks for the pull request, @Deepjyoti-Sarmah. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review completed · db3bf60e1ecd
Warning
Merge confidence: 3/5 · Review before merging · 🟠 High impact
1 P2 bug checked against the code
Java extraction now adds method nodes for fields covered by Lombok @Getter, including their return types.
Full summary
Java extraction now adds method nodes for fields covered by Lombok @Getter, including their return types. The new tests cover common getter naming, class-level annotations, and several suppression cases.
Bugs (1)
P2 · Update _java_lombok_getters to honor @Accessors(fluent = true): it creates .getValue() instead of .value(), so calls to value() do not resolve to the generated getter. Inspect source
Detailed review · checked against the code
Fluent Lombok accessors get the wrong method name
For a field using @Getter with @Accessors(fluent = true), extraction adds .getValue() even though Lombok generates value(). Calls to the generated accessor therefore do not resolve to the getter node.
Expected: Extraction creates a generated getter node named .value() so the call resolves to it.
Actually: The helper creates .getValue() instead; the resolver's name-based lookup does not match the value() call to that node.
For a Lombok @Getter field, _java_lombok_getters derives the synthetic accessor using get or is plus the capitalized field name. It does not inspect @Accessors(fluent = true), so a fluent field such as value gets a .getValue() node instead of .value(). The extractor invokes this helper while processing Java field declarations, creates the generated method node, and the Java member-call resolver indexes and looks up methods by their names. Thus a call to value() will not match the generated getValue() node. The inspected Lombok tests cover conventional getter names but do not exercise fluent accessors.
- Independent source review: Inspected the Java field-declaration path and member-call resolver; the resolver looks up methods by the callee name, and no fluent-accessor handling was found in the inspected source. The Lombok tests check ordinary getter naming and do not provide a counterexample for fluent naming.
What this review covered
- One review pass used all of its turns for reading code, so it reported from what it had already read.
- 3 of 3 changed files inspected. This is scope, not a correctness guarantee.
Code graph and static checks · 4821 functions depend on this change
Impact & health
Impact — 4821 functions depend on the 572 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1284 callers, 78 callees - worse:
walk()— 1 callers, 100 callees
Formal checks — 4821 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 3145 function(s) in the blast radius were not formally verified this run
Test selection
102 of 594 test file(s) selected (17%) via static blast radius.
tests/test_4992_ts_import_types.py— impacttests/test_astro_extraction.py— impacttests/test_binary_media_words.py— impacttests/test_build.py— impacttests/test_cache.py— impacttests/test_cache_long_paths.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cache_windows_case_4925.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_code_only_scope_4923.py— impacttests/test_cpp_alias_member_resolution.py— impacttests/test_cpp_conditional_initializers.py— impacttests/test_cpp_inherited_member_resolution.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_template_members.py— impacttests/test_csharp_extension_calls.py— impacttests/test_csharp_extension_metadata.py— impacttests/test_csharp_extension_resolution.py— impacttests/test_csharp_partial_classes.py— impacttests/test_dart.py— impacttests/test_dart_typedef.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_ext_tagged_id_clash.py— impacttests/test_extract.py— impacttests/test_extract_cache_location.py— impacttests/test_extract_cli.py— impacttests/test_extract_php_closures.py— impacttests/test_grammar_cache_key.py— impacttests/test_hook_content_freshness.py— impacttests/test_ignore_file_encoding.py— impacttests/test_import_extension_resolution.py— impacttests/test_incremental_mtime_collision.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_java_lombok_getter.py— impact, changed-testtests/test_java_member_calls.py— impacttests/test_java_nested_type_identity.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_js_member_collisions.py— impacttests/test_language_override_lifecycle.py— impacttests/test_language_overrides.py— impacttests/test_languages.py— impacttests/test_linked_worktree_reconcile.py— impact- … and 52 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Every flagged function
extract()ingraphify/extract.py:11742· 1284 callers, 78 callees: fans out to 78 callees (efferent coupling); 1284 callers depend on it (afferent coupling)walk()ingraphify/extractors/engine.py:7977· 1 callers, 100 callees: fans out to 100 callees (efferent coupling)
What does this PR do?
Fixes #5148. A call through a Lombok
@Gettergetter,Model.getInstance().work(), produced nocallsedge. On 0.9.112 with the issue's repro:The caller side is the same in both cases. What differs is
Model.java:_chain_typeingraphify/extract.pytypes each step from the_java_retof the method it names. Lombok writesgetInstance()at compile time, so the source has no node for it. The step returnsNoneandwork()stays unresolved.The fix gives a
@Getterfield the node a hand-written getter would get, as the issue suggests:The chain typing from #4306 then works unchanged.
Which getters
@Getter static Model InstancegetInstance()@Getter boolean activeisActive()@Getter boolean isReadyisReady()@Getter Boolean flaggetFlag()@Getter int a, bgetA(),getB()@Getteron the class@Getter(AccessLevel.NONE)int getX()(any case)@Getternot from Lombok (nolombok.Getter/lombok.*import, not@lombok.Getter)These follow Lombok's documented rules for
@Getter.Commits
Type of change
Verification & Invariants
Invariant: a getter that exists after Lombok runs is a member node with the field's type as its return type, the same as if it were written by hand.
Merge Danger
Door: two-way. Reverting the fix commit restores 0.9.112 output; the cache bump forces one re-extraction.
Blast Radius: small.
@Getter(or use@lombok.Getter) gain nodes..getX()node per field and itsmethodedge, so node counts and god-node rankings in Lombok-heavy repos go up._AST_CACHE_SCHEMA48 -> 49, so every cached file re-extracts once.Limitations
@Dataand@Valuealso generate getters and are not handled here.lombok.configsettings (lombok.accessors.prefix,fluent,chain) are ignored; the getter name always uses the default rule.@Getterdocs.How was this tested?
New
tests/test_java_lombok_getter.py, 11 tests:340268a7db3bf60eThe issue's CLI repro (
graphify extract . --code-only --no-cluster) on this branch gives the Lombok case the same two edges as the control case.Full suite, both trees run at the same time in the same venv:
340268a7db3bf60eThe 76 are identical. The extra one is
test_language_override_lifecycle.py::test_watch_root_config_lifecycle_rebuilds_and_refreshes_event_mapping[delete], a watch timing test with no Java in it. Run alone it passed 29/30 on this branch and 30/30 on340268a7; its[replace]twin failed only on the base tree in a run for another PR.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (No fragment change.)