internal/lsp/template: remove the skipTemplate guard
Having the explicit skipTemplate guard should not be necessary, since
with templateExtensions empty we should not detect any templates that
the user did not ask for. Remove it
For golang/vscode-go#1957
Change-Id: Idbe30bc61f47ed405d98fdb029f44a0841769ad0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/378355
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/internal/lsp/template/completion.go b/internal/lsp/template/completion.go
index 5796f5e..13dbdf1 100644
--- a/internal/lsp/template/completion.go
+++ b/internal/lsp/template/completion.go
@@ -26,9 +26,6 @@
}
func Completion(ctx context.Context, snapshot source.Snapshot, fh source.VersionedFileHandle, pos protocol.Position, context protocol.CompletionContext) (*protocol.CompletionList, error) {
- if skipTemplates(snapshot) {
- return nil, nil
- }
all := New(snapshot.Templates())
var start int // the beginning of the Token (completed or not)
syms := make(map[string]symbol)
diff --git a/internal/lsp/template/highlight.go b/internal/lsp/template/highlight.go
index 65256fc..a45abaf 100644
--- a/internal/lsp/template/highlight.go
+++ b/internal/lsp/template/highlight.go
@@ -14,9 +14,6 @@
)
func Highlight(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, loc protocol.Position) ([]protocol.DocumentHighlight, error) {
- if skipTemplates(snapshot) {
- return nil, nil
- }
buf, err := fh.Read()
if err != nil {
return nil, err
diff --git a/internal/lsp/template/implementations.go b/internal/lsp/template/implementations.go
index 2db0341..3ce67ac 100644
--- a/internal/lsp/template/implementations.go
+++ b/internal/lsp/template/implementations.go
@@ -65,18 +65,11 @@
return []*source.Diagnostic{&d}
}
-func skipTemplates(s source.Snapshot) bool {
- return len(s.View().Options().TemplateExtensions) == 0
-}
-
// Definition finds the definitions of the symbol at loc. It
// does not understand scoping (if any) in templates. This code is
// for defintions, type definitions, and implementations.
// Results only for variables and templates.
func Definition(snapshot source.Snapshot, fh source.VersionedFileHandle, loc protocol.Position) ([]protocol.Location, error) {
- if skipTemplates(snapshot) {
- return nil, nil
- }
x, _, err := symAtPosition(fh, loc)
if err != nil {
return nil, err
@@ -97,9 +90,6 @@
}
func Hover(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, position protocol.Position) (*protocol.Hover, error) {
- if skipTemplates(snapshot) {
- return nil, nil
- }
sym, p, err := symAtPosition(fh, position)
if sym == nil || err != nil {
return nil, err
@@ -131,9 +121,6 @@
}
func References(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, params *protocol.ReferenceParams) ([]protocol.Location, error) {
- if skipTemplates(snapshot) {
- return nil, nil
- }
sym, _, err := symAtPosition(fh, params.Position)
if sym == nil || err != nil || sym.name == "" {
return nil, err
@@ -157,9 +144,6 @@
}
func SemanticTokens(ctx context.Context, snapshot source.Snapshot, spn span.URI, add func(line, start, len uint32), d func() []uint32) (*protocol.SemanticTokens, error) {
- if skipTemplates(snapshot) {
- return nil, nil
- }
fh, err := snapshot.GetFile(ctx, spn)
if err != nil {
return nil, err
diff --git a/internal/lsp/template/symbols.go b/internal/lsp/template/symbols.go
index 2730ebf..5203f4c 100644
--- a/internal/lsp/template/symbols.go
+++ b/internal/lsp/template/symbols.go
@@ -194,9 +194,6 @@
// DocumentSymbols returns a heirarchy of the symbols defined in a template file.
// (The heirarchy is flat. SymbolInformation might be better.)
func DocumentSymbols(snapshot source.Snapshot, fh source.FileHandle) ([]protocol.DocumentSymbol, error) {
- if skipTemplates(snapshot) {
- return nil, nil
- }
buf, err := fh.Read()
if err != nil {
return nil, err