Skip to content

fix(apex): recognize a method return type with a dot or a generic comma (#3217) - #5627

Closed
ayushcodes10 wants to merge 1 commit into
Graphify-Labs:v8from
ayushcodes10:fix-3217-apex-method-return-type
Closed

ayushcodes10 wants to merge 1 commit into
Graphify-Labs:v8from
ayushcodes10:fix-3217-apex-method-return-type

Conversation

@ayushcodes10

Copy link
Copy Markdown
Contributor

Fixes #3217.

method_re in graphify/extractors/apex.py matched 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 v8 before changing anything:

from pathlib import Path
from graphify.extract import extract_apex
res = extract_apex(Path("Repro.cls"))
print(sorted(n["label"] for n in res["nodes"] if n["label"].startswith(".")))
['.simpleReturn()']

Only the one method with a plain String return type survives; commaGeneric, dottedReturn and nestedGeneric are 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:

['.commaGeneric()', '.dottedReturn()', '.nestedGeneric()', '.simpleReturn()']

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 ordinary if/for control flow reusing the same angle bracket shape, so the fix only catches real method signatures. Both fail against unmodified v8 (confirmed via a temporary git stash of only the extractor file) and pass with the fix.

Bumps _AST_CACHE_SCHEMA so 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 v8 too: 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.

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.
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Nov 29, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Nothing blocking · 1 possible issue to check · Merge confidence 5/5

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

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

safishamsi added a commit that referenced this pull request Nov 30, 2026
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]>
@safishamsi

Copy link
Copy Markdown
Member

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. 🙏

@safishamsi safishamsi closed this Nov 30, 2026
@conrathchad3-netizen

Copy link
Copy Markdown

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apex: method_re drops methods with commas/dots in return type (Map<String, Object>, Database.QueryLocator)

3 participants