Skip to content

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

Open
krmahadevan wants to merge 1 commit intotirth8205:mainfrom
krmahadevan:bugfix/java_methodname_retrieval_discrepancy
Open

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

Conversation

@krmahadevan
Copy link
Copy Markdown

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

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.

1 participant