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>
This commit is contained in:
parent
4bfb4c74ac
commit
ff694a2184
|
@ -6,7 +6,6 @@ package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/types"
|
"go/types"
|
||||||
|
@ -314,16 +313,6 @@ func (v *view) getFile(uri span.URI) (viewFile, error) {
|
||||||
filename := uri.Filename()
|
filename := uri.Filename()
|
||||||
var f viewFile
|
var f viewFile
|
||||||
switch ext := filepath.Ext(filename); ext {
|
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":
|
case ".mod":
|
||||||
f = &modFile{
|
f = &modFile{
|
||||||
fileBase: fileBase{
|
fileBase: fileBase{
|
||||||
|
@ -339,7 +328,16 @@ func (v *view) getFile(uri span.URI) (viewFile, error) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
default:
|
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)
|
v.mapFile(uri, f)
|
||||||
return f, nil
|
return f, nil
|
||||||
|
|
Loading…
Reference in New Issue