Repository navigation
fix(apex): recognize a method return type with a dot or a generic comma (#3217) - #5627
ayushcodes10 wants to merge 1 commit into
Conversation
method_re matched a return type against the bare class [\w<>\[\]]+,
which admits word characters and angle/square brackets only. Any
return type with a dot (Database.QueryLocator) or a comma inside a
generic argument (Map<String, Object>, List<Map<String, Id>>) never
matched, so the whole method was silently dropped: no node, no edges,
no warning.
Widen the token to a base class that also admits dots, plus one
optional generic group whose own content excludes ;{}()= so a local
declared with an initializer or a control flow line reusing the same
<...> shape still does not match.
Adds two tests: one confirming all four return type shapes from the
report now extract, one confirming the wider token still rejects a
generic local with an initializer and ordinary control flow lines.
Bumps the AST cache schema so already cached Apex extractions re run
once with the corrected method set.
|
Thanks for the pull request, @ayushcodes10. 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 review 
1 possible issue to check · High impact
The Apex extractor now recognizes method declarations with dotted or generic return types.
1 possible issue we couldn't confirm
- Apex methods returning an array of a generic type, such as
List<Account>[], are no longer detected ·graphify/extractors/apex.py:84
They don't change the score.
What this review covered
- A changed file's diff was too long to show in full, so the review may not have seen every changed line in it.
- 3 of 3 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 4690 functions depend on this change
- 1 function became more coupled.
extract_apex()(15 callers). - 62 of 658 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 9ff5166
Extractor accuracy (Swift #5641, Apex #5627, Python #5647, TypeScript #5604/#5614/#5612, Bash caller-var #5602), GitHub Actions run-step extraction (#5603), incremental correctness (#5634/#5638/#5636), symlink and semantic-cache fixes (#5617/#5618), export/report hardening and perf (#5643/#5644/#5645/#5646/#5619/#5620/#5621), and CLI/docs/skill/install work (#5629/#5628/#5626/#5624/#5623/#5625/#5642/#5583). AST cache schema 59 to 60; Swift/Apex/Python/Bash/GHA inputs re-extract on first build. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.124 (just released to PyPI), cherry-picked with your authorship preserved so it shows under your name in the history. Thanks @ayushcodes10 for recognizing Apex dotted and generic method return types — verified green in the full suite and, where applicable, smoke-tested against the published package. 🙏 |
|
I have a folder that is not good. It has my name, some stuff is me but the rest is overwhelming, what do I do? |
Fixes #3217.
method_reingraphify/extractors/apex.pymatched a method's return type against a single bare class,[\w<>\[\]]+, which admits word characters and angle or square brackets only. Any real return type with a dot (Database.QueryLocator) or a comma inside a generic argument (Map<String, Object>,List<Map<String, Id>>) never matched that class, so the whole method signature line was silently dropped: no node, no edges, no warning at all.Reproduced the issue's own repro directly against current
v8before changing anything:Only the one method with a plain
Stringreturn type survives;commaGeneric,dottedReturnandnestedGenericare gone, matching the issue exactly.Fix widens the return type token to a base class that also admits dots, plus one optional generic group. The generic group's own content excludes
;{}()=, so a local variable declared with an initializer (Map<Id, X> m = new Map<Id, X>();) or an ordinary control flow line reusing the same<...>shape still does not match, which was the caution the issue itself raised about a naive widening.After the fix, the same repro returns all four methods:
Adds two tests to
tests/test_languages.py. One confirms all four return type shapes from the report now extract with the right node set. The other confirms the widened token still rejects a generic local declared with an initializer plus ordinaryif/forcontrol flow reusing the same angle bracket shape, so the fix only catches real method signatures. Both fail against unmodifiedv8(confirmed via a temporarygit stashof only the extractor file) and pass with the fix.Bumps
_AST_CACHE_SCHEMAso already cached Apex extractions re run once to pick up the corrected method set.Verification: the two new tests pass, and the full Apex suite (15 tests) passes. The full test suite gives 12351 passed, with the 8 failures that remain all confirmed pre existing on unmodified
v8too: a long standing Erlang grammar network fetch timeout, a group of Terraform fixture parametrizations that only fail under pytest xdist parallel workers (pass every time sequentially), and a subprocess timeout flake in the R extractor test under load. The skillgen check reports all 134 artifacts clean.