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

x/tools/gopls: implementation sometimes returns duplicate implementers #35607

Closed
muirdm opened this issue Nov 15, 2019 · 8 comments
Closed

x/tools/gopls: implementation sometimes returns duplicate implementers #35607

muirdm opened this issue Nov 15, 2019 · 8 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@muirdm
Copy link

muirdm commented Nov 15, 2019

For example, when I find implementations of the "matcher" interface in tools/internal/lsp/source/completion.go, I get back:

/Users/muir/projects/tools/internal/lsp/fuzzy/matcher.go
38: type Matcher struct {
/Users/muir/projects/tools/internal/lsp/source/completion.go
118: type insensitivePrefixMatcher string
118: type insensitivePrefixMatcher string
103: type matcher interface {
108: type prefixMatcher string
108: type prefixMatcher string

Note the "insensitivePrefixMatcher" and "prefixMatcher" duplicates.

@gopherbot gopherbot added this to the Unreleased milestone Nov 15, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 15, 2019
@gopherbot
Copy link

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Nov 15, 2019
@irajdeep
Copy link

@muirdm I would be willing to work on this as my first issue, if one else is working on it.

@stamblerre
Copy link
Contributor

@irajdeep: Thanks, that'd be great! Please feel free to reach out to me here or on Gophers Slack if you need any guidance.

@irajdeep
Copy link

irajdeep commented Nov 25, 2019

Hey folks!
I tried to reproduce this issue first, In vscode I selected find all references for matcher interface. In results, I don't seem to get any of the "type(s)" which implement the interface.
The 2 results are as one can see follows:

  • The interface itself
  • And a variable of the interface type

Edit: Ignore my above comment. I just realised in vscode the actual command to find the implementations of an interface is go to implementation instead of find all references.

The output shows:

  • type prefixMatcher string
  • type insensitivePrefixMatcher string

So I reckon it works as expected and I can't reporduce the bug in the lastest version of gopls

@muirdm
Copy link
Author

muirdm commented Nov 25, 2019

Thanks for looking at this. It still happens for me on master. Below is the request/response log showing the duplicate results. Maybe VSCode is de-duping the results? Otherwise, not sure what is going on.

[Trace - 02:07:52 PM] Sending request 'textDocument/implementation - (1224)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/muir/projects/tools/internal/lsp/source/completion.go"
  },
  "position": {
    "line": 102,
    "character": 7
  }
}


[Trace - 02:07:52 PM] Received response 'textDocument/implementation - (1224)' in 14ms.
Result: [
  {
    "range": {
      "end": {
        "character": 12,
        "line": 37
      },
      "start": {
        "character": 5,
        "line": 37
      }
    },
    "uri": "file:///Users/muir/projects/tools/internal/lsp/fuzzy/matcher.go"
  },
  {
    "range": {
      "end": {
        "character": 29,
        "line": 117
      },
      "start": {
        "character": 5,
        "line": 117
      }
    },
    "uri": "file:///Users/muir/projects/tools/internal/lsp/source/completion.go"
  },
  {
    "range": {
      "end": {
        "character": 29,
        "line": 117
      },
      "start": {
        "character": 5,
        "line": 117
      }
    },
    "uri": "file:///Users/muir/projects/tools/internal/lsp/source/completion.go"
  },
  {
    "range": {
      "end": {
        "character": 18,
        "line": 107
      },
      "start": {
        "character": 5,
        "line": 107
      }
    },
    "uri": "file:///Users/muir/projects/tools/internal/lsp/source/completion.go"
  },
  {
    "range": {
      "end": {
        "character": 18,
        "line": 107
      },
      "start": {
        "character": 5,
        "line": 107
      }
    },
    "uri": "file:///Users/muir/projects/tools/internal/lsp/source/completion.go"
  }
]

@stamblerre
Copy link
Contributor

Thanks for investigating, @irajdeep. It's definitely possible that VS Code is de-duping. I actually expect that @ridersofrohan's work on fixing #35600 will also resolve this issue.

@irajdeep
Copy link

So, I checked the logs of gopls and I still can't reproduce it in v0.2.0

[Trace - 18:35:27.459 PM] Sending request 'textDocument/implementation - (14)'.
Params: {"textDocument":{"uri":"file:///Users/rdas/go/src/golang.org/x/tools/internal/lsp/source/completion.go"},"position":{"line":102,"character":9}}


[Trace - 18:35:27.461 PM] Received response 'textDocument/implementation - (14)' in 1ms.
Result: [{"uri":"file:///Users/rdas/go/src/golang.org/x/tools/internal/lsp/source/completion.go","range":{"start":{"line":117,"character":5},"end":{"line":117,"character":29}}},{"uri":"file:///Users/rdas/go/src/golang.org/x/tools/internal/lsp/source/completion.go","range":{"start":{"line":107,"character":5},"end":{"line":107,"character":18}}}]

I get 2 responses as expected. I suspect some change since v0.2.0 in master might have introduced it?

I actually expect that @ridersofrohan's work on fixing #35600 will also resolve this issue.

Cool, I will hold off working on this issue until then.

@stamblerre stamblerre modified the milestones: Unreleased, gopls v1.0 Dec 4, 2019
@ridersofrohan
Copy link

Duplicate of #35600. This seems to be resolved with the fix in that issue.

@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.4.0 Jul 22, 2020
@golang golang locked and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants