aboutsummaryrefslogtreecommitdiff
path: root/internal/lsp/references.go
diff options
context:
space:
mode:
authorRebecca Stambler <rstambler@golang.org>2019-12-17 18:57:54 -0500
committerRebecca Stambler <rstambler@golang.org>2019-12-19 20:51:25 +0000
commit2208e1677e7b76008b07abe18e667c2f04296433 (patch)
tree9ae57b3b0241b24012f10b265d0175c8d5a98cbe /internal/lsp/references.go
parent56b0b28a00f70e5545e8b1caf3ceb7c197d1924a (diff)
downloadgolang-x-tools-2208e1677e7b76008b07abe18e667c2f04296433.tar.gz
internal/lsp: eliminate source.File type and move GetFile to snapshot
This change eliminates the extra step of calling GetFile on the view and getting the FileHandle from the snapshot. It also eliminiates the redundant source.File type. Follow up changes will clean up the file kind handling, since it still exists on the fileBase type. Change-Id: I635ab8632821b36e062be5151eaab425a5698f60 Reviewed-on: https://go-review.googlesource.com/c/tools/+/211778 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
Diffstat (limited to 'internal/lsp/references.go')
-rw-r--r--internal/lsp/references.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/lsp/references.go b/internal/lsp/references.go
index 0029264a0..a61a7d4d4 100644
--- a/internal/lsp/references.go
+++ b/internal/lsp/references.go
@@ -21,15 +21,15 @@ func (s *Server) references(ctx context.Context, params *protocol.ReferenceParam
return nil, err
}
snapshot := view.Snapshot()
- f, err := view.GetFile(ctx, uri)
+ fh, err := snapshot.GetFile(ctx, uri)
if err != nil {
return nil, err
}
// Find all references to the identifier at the position.
- if f.Kind() != source.Go {
+ if fh.Identity().Kind != source.Go {
return nil, nil
}
- phs, err := snapshot.PackageHandles(ctx, snapshot.Handle(ctx, f))
+ phs, err := snapshot.PackageHandles(ctx, fh)
if err != nil {
return nil, nil
}
@@ -41,7 +41,7 @@ func (s *Server) references(ctx context.Context, params *protocol.ReferenceParam
lastIdent *source.IdentifierInfo
)
for _, ph := range phs {
- ident, err := source.Identifier(ctx, snapshot, f, params.Position, source.SpecificPackageHandle(ph.ID()))
+ ident, err := source.Identifier(ctx, snapshot, fh, params.Position, source.SpecificPackageHandle(ph.ID()))
if err != nil {
if err == source.ErrNoIdentFound {
return nil, err