aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/lsp/source/view.go
diff options
context:
space:
mode:
authorRobert Findley <rfindley@google.com>2023-01-27 16:13:41 -0500
committerRobert Findley <rfindley@google.com>2023-01-30 20:26:59 +0000
commit87d00e630f8e636e931862dcc993ca2eb9c88c1c (patch)
treedd5b8e30543d15e65a89314f9d9dc736e5894927 /gopls/internal/lsp/source/view.go
parentae242ec327b95176488336f365b0dc9c08d4e11b (diff)
downloadgolang-x-tools-87d00e630f8e636e931862dcc993ca2eb9c88c1c.tar.gz
gopls/internal/lsp: separate some requests from source.Identifier
Start to unwind source.Identifier by unrolling definition, type definition, and call hierarchy handlers. Along the way, introduce a couple primitive helper functions, which may be made obsolete in the future but allowed preserving source.Identifier behavior: - referencedObject returns the object referenced by the cursor position, as defined by source.Identifier. - mapPosition is a helper to map token.Pos to MappedRange in the narrow context of a package fileset. After this change, the only remaining use of source.Identifier is for Hover, but that is a sizeable refactoring and therefore left to a subsequent CL. Updates golang/go#57987 Change-Id: Iba4b0a574e6a6d3d54253f3b4bff8fe6e13a1b15 Reviewed-on: https://go-review.googlesource.com/c/tools/+/463955 gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'gopls/internal/lsp/source/view.go')
-rw-r--r--gopls/internal/lsp/source/view.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/gopls/internal/lsp/source/view.go b/gopls/internal/lsp/source/view.go
index cbcc9b4e6..5f4e3f567 100644
--- a/gopls/internal/lsp/source/view.go
+++ b/gopls/internal/lsp/source/view.go
@@ -697,6 +697,23 @@ const (
Work
)
+func (k FileKind) String() string {
+ switch k {
+ case Go:
+ return "go"
+ case Mod:
+ return "go.mod"
+ case Sum:
+ return "go.sum"
+ case Tmpl:
+ return "tmpl"
+ case Work:
+ return "go.work"
+ default:
+ return fmt.Sprintf("internal error: unknown file kind %d", k)
+ }
+}
+
// Analyzer represents a go/analysis analyzer with some boolean properties
// that let the user know how to use the analyzer.
type Analyzer struct {