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>
This commit is contained in:
Robert Findley 2022-01-13 11:45:38 -05:00
Родитель 99c83b8bac
Коммит d34a02b6b5
4 изменённых файлов: 0 добавлений и 25 удалений

Просмотреть файл

@ -26,9 +26,6 @@ type completer struct {
}
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)

Просмотреть файл

@ -14,9 +14,6 @@ import (
)
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

Просмотреть файл

@ -65,18 +65,11 @@ func Diagnose(f source.VersionedFileHandle) []*source.Diagnostic {
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 Definition(snapshot source.Snapshot, fh source.VersionedFileHandle, loc pro
}
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 Hover(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle,
}
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 References(ctx context.Context, snapshot source.Snapshot, fh source.FileHan
}
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

Просмотреть файл

@ -194,9 +194,6 @@ func (p *Parsed) findSymbols() {
// 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