gopls: fix various staticcheck errors

Do a pass of unused code cleanup and other staticcheck errors.

Change-Id: Iaf5d27c4f5405d4cce3e48fa06a5d46ec757de40
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257965
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
This commit is contained in:
Rob Findley 2020-09-28 14:56:33 -04:00 committed by Robert Findley
parent ffa3839b1b
commit 5272f303b6
6 changed files with 1 additions and 26 deletions

View File

@ -311,10 +311,6 @@ package main
func main() {
fmt.Println(blah.Name)
`
const want = `module mod.com
go 1.12
`
runner.Run(t, mod, func(t *testing.T, env *Env) {
env.Await(env.DiagnosticAtRegexp("go.mod", "require"))

View File

@ -14,8 +14,6 @@ import (
"go/printer"
"go/token"
"reflect"
"unicode"
"unicode/utf8"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
@ -189,16 +187,10 @@ func match(pattern, val reflect.Value) bool {
return p.Interface() == v.Interface()
}
func isWildcard(s string) bool {
rune, size := utf8.DecodeRuneInString(s)
return size == len(s) && unicode.IsLower(rune)
}
// Values/types for special cases.
var (
identType = reflect.TypeOf((*ast.Ident)(nil))
objectPtrType = reflect.TypeOf((*ast.Object)(nil))
positionType = reflect.TypeOf(token.NoPos)
callExprType = reflect.TypeOf((*ast.CallExpr)(nil))
scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
)

View File

@ -366,7 +366,7 @@ func typeCheck(ctx context.Context, snapshot *snapshot, m *metadata, mode source
if found {
return pkg, nil
}
return nil, errors.Errorf("no parsed files for package %s, expected: %s, list errors: %v", pkg.m.pkgPath, pkg.compiledGoFiles, rawErrors)
return nil, errors.Errorf("no parsed files for package %s, expected: %v, list errors: %v", pkg.m.pkgPath, pkg.compiledGoFiles, rawErrors)
} else {
pkg.types = types.NewPackage(string(m.pkgPath), string(m.name))
}

View File

@ -512,14 +512,6 @@ func (s *Session) DidModifyFiles(ctx context.Context, changes []source.FileModif
return snapshots, releases, deletionsSlice, nil
}
func (s *Session) isOpen(uri span.URI) bool {
s.overlayMu.Lock()
defer s.overlayMu.Unlock()
_, open := s.overlays[uri]
return open
}
func (s *Session) updateOverlays(ctx context.Context, changes []source.FileModification) (map[span.URI]*overlay, error) {
s.overlayMu.Lock()
defer s.overlayMu.Unlock()

View File

@ -17,7 +17,6 @@ import (
"sync"
"testing"
"golang.org/x/tools/go/packages/packagestest"
"golang.org/x/tools/internal/jsonrpc2/servertest"
"golang.org/x/tools/internal/lsp/cache"
"golang.org/x/tools/internal/lsp/cmd"
@ -31,7 +30,6 @@ import (
)
type runner struct {
exporter packagestest.Exporter
data *tests.Data
ctx context.Context
options func(*source.Options)

View File

@ -140,9 +140,6 @@ func bestMatch(fullPath string, matcher matcherFunc) (string, float64) {
// * A symbolizer determines how we extract the symbol for an object. This
// enables the 'symbolStyle' configuration option.
type symbolCollector struct {
// query is the user-supplied query passed to the Symbol method.
query string
// These types parameterize the symbol-matching pass.
matcher matcherFunc
symbolizer symbolizer