Skip to content

x/tools/gopls: find references should link concrete methods to interface methods #35999

Closed
@muirdm

Description

@muirdm

For example:

type fooer interface {
  foo()
}

type impl struct{}
func (impl) foo() {}

func _() {
  var f fooer = impl{}
  f.foo()
}

Currently if you find-references on the "foo" struct method, you don't get anything. It would be useful to return the interface method "fooer.foo". Otherwise, there is no way to find how the concrete "foo" method is used. (It would still be a two step process: first jump to the declaration of fooer.foo, then run find references again to see where it is used).

The same logic doesn't apply to the "impl" struct itself since it will actually be referenced somewhere when it is constructed.

Another idea would be to overload the find-implementations to work in reverse as well. In other words, if you run find-implementations on a concrete type or method, it would show you the interface types/methods that are implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions