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

Open
muirdm opened this issue Nov 15, 2019 · 7 comments
Labels
Milestone

Comments

@muirdm
Copy link

@muirdm 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 label Nov 15, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 15, 2019

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 label Nov 15, 2019
@irajdeep

This comment has been minimized.

Copy link

@irajdeep irajdeep commented Nov 25, 2019

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

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Nov 25, 2019

@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Nov 26, 2019

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

This comment has been minimized.

Copy link

@irajdeep irajdeep commented Nov 26, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.