internal/lsp: do not return interface itself when finding implementations
Finding implementations of an interface should not give the interface itself
as an implementation.
Fixes #35601
Change-Id: Id3352619ece90fb7ca906ddabca613742d156c76
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208667
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/lsp/source/implementation.go b/internal/lsp/source/implementation.go
index 486e3b1..7702b8e 100644
--- a/internal/lsp/source/implementation.go
+++ b/internal/lsp/source/implementation.go
@@ -77,6 +77,10 @@
if err != nil {
return nil, err
}
+ // Do not add interface itself to the list.
+ if ident.Declaration.spanRange == i.Declaration.spanRange {
+ continue
+ }
locations = append(locations, protocol.Location{
URI: protocol.NewURI(ident.Declaration.URI()),
Range: decRange,