Skip to content

fix(parser): extract Java method names from the name field (#804) - #808

Open
arimu1 wants to merge 1 commit into
tirth8205:mainfrom
arimu1:fix/804-java-get-name-field
Open

fix(parser): extract Java method names from the name field (#804)#808
arimu1 wants to merge 1 commit into
tirth8205:mainfrom
arimu1:fix/804-java-get-name-field

Conversation

@arimu1

@arimu1 arimu1 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Linked issue

Fixes #804

What & why

During the #794 review, C# method_declaration / constructor_declaration names were switched to the grammar name field via child_by_field_name("name"). The Java branch still walked for the first identifier child — the same fragile pattern that misnamed C# methods when a non-generic return type is itself an identifier.

Java return types usually parse as type_identifier today, so there is no known misnaming, but the name-field approach is more robust and keeps the Java and C# branches consistent. Also drops the redundant second Java-only method_declaration identifier walk further down _get_name.

How it was tested

uv run pytest tests/test_multilang.py::TestJavaParsing tests/test_multilang.py::TestJavaMethodNames tests/test_multilang.py::TestCSharpMethodNames -v --tb=short -q
# 10 passed

uv run --extra dev ruff check code_review_graph/parser.py tests/test_multilang.py
# All checks passed

Checklist

  • Tests added for new functionality
  • All tests pass: focused Java/C# name tests above
  • Linting passes: uv run --extra dev ruff check code_review_graph/parser.py tests/test_multilang.py
  • Type checking passes: uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional (not re-run; change is a short name-field read with no new types)
  • Lines are at most 100 characters
  • Docs updated where behavior changed (CHANGELOG.md)

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.30 (LOW) — 5 changed function(s)/class(es), 0 affected flow(s), 2 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.30 low code_review_graph/parser.py::CodeParser code_review_graph/parser.py:2403 yes
0.30 low code_review_graph/parser.py::CodeParser._get_name code_review_graph/parser.py:14387 no
0.25 low tests/test_multilang.py::TestJavaMethodNames.test_methods_and_constructors_use_name_field tests/test_multilang.py:225 (test)
0.10 low tests/test_multilang.py::TestJavaMethodNames._parse tests/test_multilang.py:220 yes
0.05 low tests/test_multilang.py::TestJavaMethodNames tests/test_multilang.py:214 no

Test gaps

  • code_review_graph/parser.py::CodeParser._get_name (code_review_graph/parser.py:14387)
  • tests/test_multilang.py::TestJavaMethodNames (tests/test_multilang.py:214)

Token savings: this graph-backed report used ~223,753 fewer tokens (~99%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

Java method_declaration/constructor_declaration now use
child_by_field_name("name") like the C# branch (tirth8205#794), replacing the
first-identifier walk and removing the redundant second Java path.

Fixes tirth8205#804
@arimu1
arimu1 force-pushed the fix/804-java-get-name-field branch from e19b106 to 74cae99 Compare August 1, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java _get_name still uses the first-identifier heuristic instead of the grammar name field

1 participant