Skip to content

fix(go): resolve method names from field_identifier in method_declaration#166

Merged
tirth8205 merged 1 commit intotirth8205:mainfrom
singh-aashutosh:singh-aashutosh/go-method-field-identifier-fix
Apr 11, 2026
Merged

fix(go): resolve method names from field_identifier in method_declaration#166
tirth8205 merged 1 commit intotirth8205:mainfrom
singh-aashutosh:singh-aashutosh/go-method-field-identifier-fix

Conversation

@singh-aashutosh
Copy link
Copy Markdown
Contributor

Summary

Go methods were often missing from the knowledge graph or stored under the wrong name (for example int64, string, error) because _get_name() did not match how tree-sitter-go models method names.

Root cause

For method_declaration, the method name is a field_identifier child, not an identifier. The generic loop only matches identifier, type_identifier, and similar. That leads to:

  • Methods without a result type: no matching name → the method is skipped entirely.
  • Methods with a named result type (e.g. int64): the first type_identifier after the parameter lists is the return type, which was incorrectly used as the function name.

Change

In _get_name(), add a Go-specific branch for method_declaration that returns the field_identifier text, placed before the generic child loop (same ordering idea as the existing C/C++ handling so return types are not mistaken for names).

Verification

  • Parse a small file with func (s *T) Foo() {} and func (s *T) Bar() int64 { return 0 }; both should emit Function nodes named Foo and Bar, not int64.
  • Parse a large service.go with many receiver methods; Function count should match expectations and bogus int64 / string / error “functions” from return types should disappear.

@tirth8205 tirth8205 merged commit 1f0d0a8 into tirth8205:main Apr 11, 2026
1 check passed
tirth8205 added a commit that referenced this pull request Apr 11, 2026
Unreleased fixes since v2.2.2 that users are complaining about:
- #208 Claude Code hook schema (fixes #97, #138, #163, #168, #172, #182,
  #188, #191, #201) — v2.2.2 generates an invalid hooks schema and
  timeouts in ms instead of seconds; PreCommit is also not a real event.
- #205 SQLite transaction nesting (fixes #110, #135, #181) — implicit
  transactions from the legacy sqlite3 default caused "cannot start a
  transaction within a transaction" on update.
- #166 Go method receivers resolved from field_identifier.
- #170 UTF-8 decode errors in detect_changes (fixes #169).
- #142 --platform target filters (fixes #133).
- #213 / #183 large-repo community detection hangs.
- #220 CI lint + tomllib on Python 3.10.
- #159 missing pytest-cov dev dep.
- #154 JSX component CALLS edges.

Plus features: #177 Codex, #165 Luau (#153), #217 REFERENCES edge,
#215 recurse_submodules, #185 gitignore default (#175), #171 gitignore
docs (#157).

Verified locally on Python 3.11: ruff clean, mypy clean, bandit clean,
691 tests pass, coverage 73.72%.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tirth8205 tirth8205 mentioned this pull request Apr 11, 2026
5 tasks
tirth8205 added a commit that referenced this pull request Apr 11, 2026
Unreleased fixes since v2.2.2 that users are complaining about:
- #208 Claude Code hook schema (fixes #97, #138, #163, #168, #172, #182,
  #188, #191, #201) — v2.2.2 generates an invalid hooks schema and
  timeouts in ms instead of seconds; PreCommit is also not a real event.
- #205 SQLite transaction nesting (fixes #110, #135, #181) — implicit
  transactions from the legacy sqlite3 default caused "cannot start a
  transaction within a transaction" on update.
- #166 Go method receivers resolved from field_identifier.
- #170 UTF-8 decode errors in detect_changes (fixes #169).
- #142 --platform target filters (fixes #133).
- #213 / #183 large-repo community detection hangs.
- #220 CI lint + tomllib on Python 3.10.
- #159 missing pytest-cov dev dep.
- #154 JSX component CALLS edges.

Plus features: #177 Codex, #165 Luau (#153), #217 REFERENCES edge,
#215 recurse_submodules, #185 gitignore default (#175), #171 gitignore
docs (#157).

Verified locally on Python 3.11: ruff clean, mypy clean, bandit clean,
691 tests pass, coverage 73.72%.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
krmahadevan added a commit to krmahadevan/code-review-graph that referenced this pull request Apr 14, 2026
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 added a commit to krmahadevan/code-review-graph that referenced this pull request Apr 14, 2026
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 added a commit to krmahadevan/code-review-graph that referenced this pull request Apr 14, 2026
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.
tirth8205 pushed a commit that referenced this pull request Apr 18, 2026
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.
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.

3 participants