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>
diff --git a/gopls/internal/regtest/modfile_test.go b/gopls/internal/regtest/modfile_test.go
index aa5e864..11fe302 100644
--- a/gopls/internal/regtest/modfile_test.go
+++ b/gopls/internal/regtest/modfile_test.go
@@ -312,10 +312,6 @@
 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"))
 		env.Sandbox.RunGoCommand(env.Ctx, "", "mod", []string{"tidy"})
diff --git a/internal/lsp/analysis/simplifycompositelit/simplifycompositelit.go b/internal/lsp/analysis/simplifycompositelit/simplifycompositelit.go
index eae53db..c91fc75 100644
--- a/internal/lsp/analysis/simplifycompositelit/simplifycompositelit.go
+++ b/internal/lsp/analysis/simplifycompositelit/simplifycompositelit.go
@@ -14,8 +14,6 @@
 	"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 @@
 	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))
 )
diff --git a/internal/lsp/cache/check.go b/internal/lsp/cache/check.go
index 2a6210c..25f3147 100644
--- a/internal/lsp/cache/check.go
+++ b/internal/lsp/cache/check.go
@@ -366,7 +366,7 @@
 		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))
 	}
diff --git a/internal/lsp/cache/session.go b/internal/lsp/cache/session.go
index c1704e3..457b422 100644
--- a/internal/lsp/cache/session.go
+++ b/internal/lsp/cache/session.go
@@ -512,14 +512,6 @@
 	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()
diff --git a/internal/lsp/cmd/test/cmdtest.go b/internal/lsp/cmd/test/cmdtest.go
index cdda08b..457fdbb 100644
--- a/internal/lsp/cmd/test/cmdtest.go
+++ b/internal/lsp/cmd/test/cmdtest.go
@@ -17,7 +17,6 @@
 	"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 @@
 )
 
 type runner struct {
-	exporter    packagestest.Exporter
 	data        *tests.Data
 	ctx         context.Context
 	options     func(*source.Options)
diff --git a/internal/lsp/source/workspace_symbol.go b/internal/lsp/source/workspace_symbol.go
index daff462..25010de 100644
--- a/internal/lsp/source/workspace_symbol.go
+++ b/internal/lsp/source/workspace_symbol.go
@@ -140,9 +140,6 @@
 //  * 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