Skip to content

fix(java): extract method name from identifier, not return type#275

Merged
tirth8205 merged 1 commit intotirth8205:mainfrom
krmahadevan:bugfix/java_methodname_retrieval_discrepancy
Apr 18, 2026
Merged

fix(java): extract method name from identifier, not return type#275
tirth8205 merged 1 commit intotirth8205:mainfrom
krmahadevan:bugfix/java_methodname_retrieval_discrepancy

Conversation

@krmahadevan
Copy link
Copy Markdown
Contributor

tree-sitter-java places type_identifier (return type) before identifier (method name) in method_declaration nodes.
The generic _get_name() loop matched type_identifier first, causing methods to be indexed under their return type instead of their actual name.

For example:

  • public String getName() was indexed as "String" instead of "getName", and
  • public ConfigBean getUtilityIngestionBean()was indexed as "ConfigBean".

This broke callers_of,callees_of, and
children_of queries for any Java method with a non-void, non-generic return type.

Adds a Java-specific branch in _get_name() that returns the first identifier child for method_declaration nodes, following the same pattern as the Go fix (field_identifier) from PR #166.

Kotlin & Scala is unaffected — its syntax places the name before the return type.

@krmahadevan krmahadevan force-pushed the bugfix/java_methodname_retrieval_discrepancy branch from d78a14e to bb33628 Compare April 14, 2026 14:39
@krmahadevan
Copy link
Copy Markdown
Contributor Author

@tirth8205 - Can you please help review this PR ?

I am leveraging code-review-graph tool at work, to build a claude skill for code refactoring and I noticed this gap because of which Claude is falling back to using Grep/Blob/File instead of using this tool. That will increase token usage and so I was hoping that we could get this PR reviewed.

This is the other PR #278

tree-sitter-java places type_identifier (return type) before identifier
(method name) in method_declaration nodes.
The generic _get_name() loop matched type_identifier first,
causing methods to be indexed under their return type instead of their actual name.

For example:

* `public String getName()` was indexed as "String" instead of "getName", and
* `public ConfigBean getUtilityIngestionBean()`was indexed as "ConfigBean".

This broke callers_of,callees_of, and
children_of queries for any Java method with a non-void,
non-generic return type.

Adds a Java-specific branch in _get_name() that returns the first
identifier child for method_declaration nodes, following the same
pattern as the Go fix (field_identifier) from PR tirth8205#166.

Kotlin & Scala  is unaffected — its syntax places the name before the return type.
@krmahadevan krmahadevan force-pushed the bugfix/java_methodname_retrieval_discrepancy branch from bb33628 to a6b620e Compare April 14, 2026 15:19
@krmahadevan
Copy link
Copy Markdown
Contributor Author

This is the 3rd PR #280

All of these will basically help us reduce claude token usage when working with java codebases wherein we use code-review-graph tool

@krmahadevan
Copy link
Copy Markdown
Contributor Author

@tirth8205 - ping! Gentle reminder, if you could please help with these PRs.

@tirth8205 tirth8205 merged commit 9a88f20 into tirth8205:main Apr 18, 2026
1 check passed
npkriami18 pushed a commit to npkriami18/code-review-graph that referenced this pull request Apr 21, 2026
…h8205#275)

tree-sitter-java places type_identifier (return type) before identifier
(method name) in method_declaration nodes.
The generic _get_name() loop matched type_identifier first,
causing methods to be indexed under their return type instead of their actual name.

For example:

* `public String getName()` was indexed as "String" instead of "getName", and
* `public ConfigBean getUtilityIngestionBean()`was indexed as "ConfigBean".

This broke callers_of,callees_of, and
children_of queries for any Java method with a non-void,
non-generic return type.

Adds a Java-specific branch in _get_name() that returns the first
identifier child for method_declaration nodes, following the same
pattern as the Go fix (field_identifier) from PR tirth8205#166.

Kotlin & Scala  is unaffected — its syntax places the name before the return type.

(cherry picked from commit 9a88f20)
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.

2 participants