Skip to content

Commit

Permalink
internal/lsp: stop requiring a .go extension for all Go files
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Cottrell <[email protected]>
  • Loading branch information
stamblerre committed Jun 11, 2019
1 parent 4bfb4c7 commit ff694a2
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions internal/lsp/cache/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package cache

import (
"context"
"fmt"
"go/ast"
"go/parser"
"go/types"
Expand Down Expand Up @@ -314,16 +313,6 @@ func (v *view) getFile(uri span.URI) (viewFile, error) {
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{
Expand All @@ -339,7 +328,16 @@ func (v *view) getFile(uri span.URI) (viewFile, error) {
},
}
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
Expand Down

0 comments on commit ff694a2

Please sign in to comment.