Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Candidates method file match #234

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resolver/candidates.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (c ValueCandidates) Filter(typ *Type) ValueCandidates {

func (r *Resolver) Candidates(loc *source.Location) []string {
for _, file := range r.files {
if strings.HasSuffix(file.GetName(), loc.FileName) {
if strings.HasSuffix(loc.FileName, file.GetName()) {
protoPkgName := file.GetPackage()
switch {
case loc.Message != nil:
Expand Down
2 changes: 1 addition & 1 deletion source/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (f *File) buildLocation(ctx *findContext) *Location {

// FindLocationByPos returns the corresponding location information from the position in the source code.
func (f *File) FindLocationByPos(pos Position) *Location {
ctx := &findContext{fileName: f.fileNode.Name()}
ctx := &findContext{fileName: f.Path()}
for _, decl := range f.fileNode.Decls {
ctx := ctx.child()
switch n := decl.(type) {
Expand Down
20 changes: 10 additions & 10 deletions source/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 47,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Service: &source.Service{
Name: "FederationService",
Method: &source.Method{
Expand All @@ -54,7 +54,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 16,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Service: &source.Service{
Name: "FederationService",
Method: &source.Method{
Expand All @@ -72,7 +72,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 20,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "Post",
Option: &source.MessageOption{
Expand All @@ -92,7 +92,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 29,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "Post",
Option: &source.MessageOption{
Expand All @@ -114,7 +114,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 39,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "Post",
Option: &source.MessageOption{
Expand All @@ -136,7 +136,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 47,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "GetPostResponse",
Field: &source.Field{
Expand All @@ -154,7 +154,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 15,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "GetPostResponse",
Option: &source.MessageOption{
Expand All @@ -176,7 +176,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 24,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "GetPostResponse",
Option: &source.MessageOption{
Expand All @@ -198,7 +198,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 34,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "GetPostResponse",
Option: &source.MessageOption{
Expand All @@ -220,7 +220,7 @@ func TestFile_FindLocationByPos(t *testing.T) {
Col: 26,
},
expected: &source.Location{
FileName: "service.proto",
FileName: "testdata/service.proto",
Message: &source.Message{
Name: "Post",
Option: &source.MessageOption{
Expand Down
Loading