internal/lsp: stop requiring a .go extension for all Go files
This change should fix the TryBot failures exposed by
https://golang.org/cl/181317.
Updates golang/go#31561
Change-Id: Ie77c9e3bfd6825dcd2608523e72f804f81d3f48c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181546
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index b5b5968..7d81fb0 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -6,7 +6,6 @@
import (
"context"
- "fmt"
"go/ast"
"go/parser"
"go/types"
@@ -314,16 +313,6 @@
filename := uri.Filename()
var f viewFile
switch ext := filepath.Ext(filename); ext {
- case ".go":
- f = &goFile{
- fileBase: fileBase{
- view: v,
- fname: filename,
- },
- }
- v.session.filesWatchMap.Watch(uri, func() {
- f.(*goFile).invalidateContent()
- })
case ".mod":
f = &modFile{
fileBase: fileBase{
@@ -339,7 +328,16 @@
},
}
default:
- return nil, fmt.Errorf("unsupported file extension: %s", ext)
+ // Assume that all other files are Go files, regardless of extension.
+ f = &goFile{
+ fileBase: fileBase{
+ view: v,
+ fname: filename,
+ },
+ }
+ v.session.filesWatchMap.Watch(uri, func() {
+ f.(*goFile).invalidateContent()
+ })
}
v.mapFile(uri, f)
return f, nil