fix(go): resolve method names from field_identifier in method_declaration#166
Open
singh-aashutosh wants to merge 1 commit intotirth8205:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 afield_identifierchild, not anidentifier. The generic loop only matchesidentifier,type_identifier, and similar. That leads to:int64): the firsttype_identifierafter the parameter lists is the return type, which was incorrectly used as the function name.Change
In
_get_name(), add a Go-specific branch formethod_declarationthat returns thefield_identifiertext, placed before the generic child loop (same ordering idea as the existing C/C++ handling so return types are not mistaken for names).Verification
func (s *T) Foo() {}andfunc (s *T) Bar() int64 { return 0 }; both should emitFunctionnodes namedFooandBar, notint64.service.gowith many receiver methods;Functioncount should match expectations and bogusint64/string/error“functions” from return types should disappear.