Skip to content

x/tools/gopls: prune noisy indirect references from textDocument/references results #42350

@findleyr

Description

@findleyr

Currently, when finding references for a type T, gopls also returns references to interfaces that T implements.

This can be a source of significant noise in the results, particularly for LSP clients that apply their own sorting on top of the results returned by gopls. Consider the following:

type T struct{}
func (T) String() string { return "" }
func useT(T) {}

In this case, the type T implements the fmt.Stringer interface. Finding references to such a T defined in the x/tools repo results in both T.String and useT (the only direct references to T) not being in the first page of results.

I feel like we can do better, either by excluding all indirect references to T, restricting indirect references to those interfaces defined in the same package as T, or adding special handling for extremely common interfaces such as fmt.Stringer.

CC @heschik @stamblerre

Metadata

Metadata

Assignees

No one assigned

    Labels

    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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions