diff options
author | Rebecca Stambler <rstambler@golang.org> | 2019-09-04 17:23:20 -0400 |
---|---|---|
committer | Rebecca Stambler <rstambler@golang.org> | 2019-09-05 03:51:44 +0000 |
commit | df305b82d218535fccc89e230f23fef4c00302fe (patch) | |
tree | c82f9f7a0d3de801aadde38c38333d7d05bd54d0 /internal/lsp/references.go | |
parent | 70bfb60283fe5570e0925338ba880ef29421969a (diff) | |
download | golang-x-tools-df305b82d218535fccc89e230f23fef4c00302fe.tar.gz |
internal/lsp: fix declarations in references
Fixes golang/go#34087
Change-Id: I854c03cd124fe783f838dc53ee76cec5fffa563b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193379
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Diffstat (limited to 'internal/lsp/references.go')
-rw-r--r-- | internal/lsp/references.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/internal/lsp/references.go b/internal/lsp/references.go index 28d658716..ea238d4a3 100644 --- a/internal/lsp/references.go +++ b/internal/lsp/references.go @@ -57,17 +57,22 @@ func (s *Server) references(ctx context.Context, params *protocol.ReferenceParam // it is added to the beginning of the list if IncludeDeclaration // was specified. if params.Context.IncludeDeclaration { - rng, err := ident.Declaration.Range() + decSpan, err := ident.Declaration.Span() if err != nil { return nil, err } - locations = append([]protocol.Location{ - { - URI: protocol.NewURI(ident.Declaration.URI()), - Range: rng, - }, - }, locations...) - + if !seen[decSpan] { + rng, err := ident.Declaration.Range() + if err != nil { + return nil, err + } + locations = append([]protocol.Location{ + { + URI: protocol.NewURI(ident.Declaration.URI()), + Range: rng, + }, + }, locations...) + } } return locations, nil } |