diff --git a/internal/lsp/cache/analysis.go b/internal/lsp/cache/analysis.go index 9a6478b0f6..a81a0b81b5 100644 --- a/internal/lsp/cache/analysis.go +++ b/internal/lsp/cache/analysis.go @@ -137,7 +137,7 @@ func (s *snapshot) actionHandle(ctx context.Context, id packageID, a *analysis.A h := s.view.session.cache.store.Bind(buildActionKey(a, ph), func(ctx context.Context) interface{} { // Analyze dependencies first. - results, err := execAll(ctx, fset, deps) + results, err := execAll(ctx, deps) if err != nil { return &actionData{ err: err, @@ -174,7 +174,7 @@ func (act *actionHandle) String() string { return fmt.Sprintf("%s@%s", act.analyzer, act.pkg.PkgPath()) } -func execAll(ctx context.Context, fset *token.FileSet, actions []*actionHandle) (map[*actionHandle]*actionData, error) { +func execAll(ctx context.Context, actions []*actionHandle) (map[*actionHandle]*actionData, error) { var mu sync.Mutex results := make(map[*actionHandle]*actionData) diff --git a/internal/lsp/cache/errors.go b/internal/lsp/cache/errors.go index aba5f07faa..4ea0cf01fe 100644 --- a/internal/lsp/cache/errors.go +++ b/internal/lsp/cache/errors.go @@ -45,7 +45,7 @@ func sourceError(ctx context.Context, fset *token.FileSet, pkg *pkg, e interface spn = parseGoListError(e.Msg) // We may not have been able to parse a valid span. - if _, err := spanToRange(ctx, pkg, spn); err != nil { + if _, err := spanToRange(pkg, spn); err != nil { return &source.Error{ URI: spn.URI(), Message: msg, @@ -58,7 +58,7 @@ func sourceError(ctx context.Context, fset *token.FileSet, pkg *pkg, e interface case *scanner.Error: msg = e.Msg kind = source.ParseError - spn, err = scannerErrorRange(ctx, fset, pkg, e.Pos) + spn, err = scannerErrorRange(fset, pkg, e.Pos) if err != nil { event.Error(ctx, "no span for scanner.Error pos", err, tag.Package.Of(pkg.ID())) spn = span.Parse(e.Pos.String()) @@ -71,7 +71,7 @@ func sourceError(ctx context.Context, fset *token.FileSet, pkg *pkg, e interface } msg = e[0].Msg kind = source.ParseError - spn, err = scannerErrorRange(ctx, fset, pkg, e[0].Pos) + spn, err = scannerErrorRange(fset, pkg, e[0].Pos) if err != nil { event.Error(ctx, "no span for scanner.Error pos", err, tag.Package.Of(pkg.ID())) spn = span.Parse(e[0].Pos.String()) @@ -92,16 +92,16 @@ func sourceError(ctx context.Context, fset *token.FileSet, pkg *pkg, e interface msg = e.Message kind = source.Analysis category = e.Category - fixes, err = suggestedFixes(ctx, fset, pkg, e) + fixes, err = suggestedFixes(fset, pkg, e) if err != nil { return nil, err } - related, err = relatedInformation(ctx, fset, pkg, e) + related, err = relatedInformation(fset, pkg, e) if err != nil { return nil, err } } - rng, err := spanToRange(ctx, pkg, spn) + rng, err := spanToRange(pkg, spn) if err != nil { return nil, err } @@ -116,7 +116,7 @@ func sourceError(ctx context.Context, fset *token.FileSet, pkg *pkg, e interface }, nil } -func suggestedFixes(ctx context.Context, fset *token.FileSet, pkg *pkg, diag *analysis.Diagnostic) ([]source.SuggestedFix, error) { +func suggestedFixes(fset *token.FileSet, pkg *pkg, diag *analysis.Diagnostic) ([]source.SuggestedFix, error) { var fixes []source.SuggestedFix for _, fix := range diag.SuggestedFixes { edits := make(map[span.URI][]protocol.TextEdit) @@ -125,7 +125,7 @@ func suggestedFixes(ctx context.Context, fset *token.FileSet, pkg *pkg, diag *an if err != nil { return nil, err } - rng, err := spanToRange(ctx, pkg, spn) + rng, err := spanToRange(pkg, spn) if err != nil { return nil, err } @@ -142,14 +142,14 @@ func suggestedFixes(ctx context.Context, fset *token.FileSet, pkg *pkg, diag *an return fixes, nil } -func relatedInformation(ctx context.Context, fset *token.FileSet, pkg *pkg, diag *analysis.Diagnostic) ([]source.RelatedInformation, error) { +func relatedInformation(fset *token.FileSet, pkg *pkg, diag *analysis.Diagnostic) ([]source.RelatedInformation, error) { var out []source.RelatedInformation for _, related := range diag.Related { spn, err := span.NewRange(fset, related.Pos, related.End).Span() if err != nil { return nil, err } - rng, err := spanToRange(ctx, pkg, spn) + rng, err := spanToRange(pkg, spn) if err != nil { return nil, err } @@ -200,7 +200,7 @@ func typeErrorRange(ctx context.Context, fset *token.FileSet, pkg *pkg, pos toke }.Span() } -func scannerErrorRange(ctx context.Context, fset *token.FileSet, pkg *pkg, posn token.Position) (span.Span, error) { +func scannerErrorRange(fset *token.FileSet, pkg *pkg, posn token.Position) (span.Span, error) { ph, _, err := source.FindFileInPackage(pkg, span.URIFromPath(posn.Filename)) if err != nil { return span.Span{}, err @@ -219,7 +219,7 @@ func scannerErrorRange(ctx context.Context, fset *token.FileSet, pkg *pkg, posn // spanToRange converts a span.Span to a protocol.Range, // assuming that the span belongs to the package whose diagnostics are being computed. -func spanToRange(ctx context.Context, pkg *pkg, spn span.Span) (protocol.Range, error) { +func spanToRange(pkg *pkg, spn span.Span) (protocol.Range, error) { ph, _, err := source.FindFileInPackage(pkg, spn.URI()) if err != nil { return protocol.Range{}, err diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go index 7e91753dac..dab568cd9c 100644 --- a/internal/lsp/cache/load.go +++ b/internal/lsp/cache/load.go @@ -114,7 +114,7 @@ func (s *snapshot) load(ctx context.Context, scopes ...interface{}) error { continue } // Skip test main packages. - if isTestMain(ctx, pkg, s.view.gocache) { + if isTestMain(pkg, s.view.gocache) { continue } // Set the metadata for this package. @@ -161,7 +161,7 @@ func (s *snapshot) setMetadata(ctx context.Context, pkgPath packagePath, pkg *pa } copied := map[packageID]struct{}{ - id: struct{}{}, + id: {}, } for k, v := range seen { copied[k] = v @@ -218,7 +218,7 @@ func (s *snapshot) setMetadata(ctx context.Context, pkgPath packagePath, pkg *pa return m, nil } -func isTestMain(ctx context.Context, pkg *packages.Package, gocache string) bool { +func isTestMain(pkg *packages.Package, gocache string) bool { // Test mains must have an import path that ends with ".test". if !strings.HasSuffix(pkg.PkgPath, ".test") { return false diff --git a/internal/lsp/cache/mod.go b/internal/lsp/cache/mod.go index af4fd8d1c1..1cccaa4c90 100644 --- a/internal/lsp/cache/mod.go +++ b/internal/lsp/cache/mod.go @@ -402,7 +402,7 @@ func (s *snapshot) ModTidyHandle(ctx context.Context, realfh source.FileHandle) data.missingDeps[req.Mod.Path] = req } } - data.parseErrors, data.err = modRequireErrors(ctx, options, data) + data.parseErrors, data.err = modRequireErrors(options, data) for _, req := range data.missingDeps { if data.unusedDeps[req.Mod.Path] != nil { @@ -464,7 +464,7 @@ func extractModParseErrors(ctx context.Context, uri span.URI, m *protocol.Column // modRequireErrors extracts the errors that occur on the require directives. // It checks for directness issues and unused dependencies. -func modRequireErrors(ctx context.Context, options source.Options, data *modData) ([]source.Error, error) { +func modRequireErrors(options source.Options, data *modData) ([]source.Error, error) { var errors []source.Error for dep, req := range data.unusedDeps { if req.Syntax == nil { @@ -472,7 +472,7 @@ func modRequireErrors(ctx context.Context, options source.Options, data *modData } // Handle dependencies that are incorrectly labeled indirect and vice versa. if data.missingDeps[dep] != nil && req.Indirect != data.missingDeps[dep].Indirect { - directErr, err := modDirectnessErrors(ctx, options, data, req) + directErr, err := modDirectnessErrors(options, data, req) if err != nil { return nil, err } @@ -484,7 +484,7 @@ func modRequireErrors(ctx context.Context, options source.Options, data *modData if err != nil { return nil, err } - edits, err := dropDependencyEdits(ctx, options, data, req) + edits, err := dropDependencyEdits(options, data, req) if err != nil { return nil, err } @@ -504,7 +504,7 @@ func modRequireErrors(ctx context.Context, options source.Options, data *modData } // modDirectnessErrors extracts errors when a dependency is labeled indirect when it should be direct and vice versa. -func modDirectnessErrors(ctx context.Context, options source.Options, data *modData, req *modfile.Require) (source.Error, error) { +func modDirectnessErrors(options source.Options, data *modData, req *modfile.Require) (source.Error, error) { rng, err := rangeFromPositions(data.origfh.Identity().URI, data.origMapper, req.Syntax.Start, req.Syntax.End) if err != nil { return source.Error{}, err @@ -520,7 +520,7 @@ func modDirectnessErrors(ctx context.Context, options source.Options, data *modD return source.Error{}, err } } - edits, err := changeDirectnessEdits(ctx, options, data, req, false) + edits, err := changeDirectnessEdits(options, data, req, false) if err != nil { return source.Error{}, err } @@ -536,7 +536,7 @@ func modDirectnessErrors(ctx context.Context, options source.Options, data *modD }, nil } // If the dependency should be indirect, add the // indirect. - edits, err := changeDirectnessEdits(ctx, options, data, req, true) + edits, err := changeDirectnessEdits(options, data, req, true) if err != nil { return source.Error{}, err } @@ -564,7 +564,7 @@ func modDirectnessErrors(ctx context.Context, options source.Options, data *modD // module t // // go 1.11 -func dropDependencyEdits(ctx context.Context, options source.Options, data *modData, req *modfile.Require) ([]protocol.TextEdit, error) { +func dropDependencyEdits(options source.Options, data *modData, req *modfile.Require) ([]protocol.TextEdit, error) { if err := data.origParsedFile.DropRequire(req.Mod.Path); err != nil { return nil, err } @@ -598,7 +598,7 @@ func dropDependencyEdits(ctx context.Context, options source.Options, data *modD // go 1.11 // // require golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee // indirect -func changeDirectnessEdits(ctx context.Context, options source.Options, data *modData, req *modfile.Require, indirect bool) ([]protocol.TextEdit, error) { +func changeDirectnessEdits(options source.Options, data *modData, req *modfile.Require, indirect bool) ([]protocol.TextEdit, error) { var newReq []*modfile.Require prevIndirect := false // Change the directness in the matching require statement. diff --git a/internal/lsp/cache/parse.go b/internal/lsp/cache/parse.go index 9b52f9e934..3c796c9c1a 100644 --- a/internal/lsp/cache/parse.go +++ b/internal/lsp/cache/parse.go @@ -307,7 +307,7 @@ func fixSrc(f *ast.File, tok *token.File, src []byte) (newSrc []byte) { case *ast.BlockStmt: newSrc = fixMissingCurlies(f, n, parent, tok, src) case *ast.SelectorExpr: - newSrc = fixDanglingSelector(f, n, parent, tok, src) + newSrc = fixDanglingSelector(n, tok, src) } return newSrc == nil @@ -460,7 +460,7 @@ func fixEmptySwitch(body *ast.BlockStmt, tok *token.File, src []byte) { // To fix completion at "<>", we insert a real "_" after the "." so the // following declaration of "x" can be parsed and type checked // normally. -func fixDanglingSelector(f *ast.File, s *ast.SelectorExpr, parent ast.Node, tok *token.File, src []byte) []byte { +func fixDanglingSelector(s *ast.SelectorExpr, tok *token.File, src []byte) []byte { if !isPhantomUnderscore(s.Sel, tok, src) { return nil } diff --git a/internal/lsp/code_action.go b/internal/lsp/code_action.go index f3dd2c2211..75a2cae924 100644 --- a/internal/lsp/code_action.go +++ b/internal/lsp/code_action.go @@ -111,7 +111,7 @@ func (s *Server) codeAction(ctx context.Context, params *protocol.CodeActionPara } // Get any actions that might be attributed to missing modules in the go.mod file. - actions, err := mod.SuggestedGoFixes(ctx, snapshot, fh, diagnostics) + actions, err := mod.SuggestedGoFixes(ctx, snapshot, diagnostics) if err != nil { event.Error(ctx, "quick fixes failed", err, tag.URI.Of(uri)) } diff --git a/internal/lsp/mod/diagnostics.go b/internal/lsp/mod/diagnostics.go index 16aebe0a79..d4ad606cd5 100644 --- a/internal/lsp/mod/diagnostics.go +++ b/internal/lsp/mod/diagnostics.go @@ -44,7 +44,7 @@ func Diagnostics(ctx context.Context, snapshot source.Snapshot) (map[source.File } reports := map[source.FileIdentity][]source.Diagnostic{ - realfh.Identity(): []source.Diagnostic{}, + realfh.Identity(): {}, } for _, e := range parseErrors { diag := source.Diagnostic{ @@ -117,7 +117,7 @@ func SuggestedFixes(ctx context.Context, snapshot source.Snapshot, realfh source return actions } -func SuggestedGoFixes(ctx context.Context, snapshot source.Snapshot, gofh source.FileHandle, diags []protocol.Diagnostic) ([]protocol.CodeAction, error) { +func SuggestedGoFixes(ctx context.Context, snapshot source.Snapshot, diags []protocol.Diagnostic) ([]protocol.CodeAction, error) { // TODO: We will want to support diagnostics for go.mod files even when the -modfile flag is turned off. realURI, tempURI := snapshot.View().ModFiles() diff --git a/internal/lsp/source/completion.go b/internal/lsp/source/completion.go index 995fd45de7..7637b3b8d8 100644 --- a/internal/lsp/source/completion.go +++ b/internal/lsp/source/completion.go @@ -488,7 +488,7 @@ func Completion(ctx context.Context, snapshot Snapshot, fh FileHandle, protoPos path: path, pos: pos, seen: make(map[types.Object]bool), - enclosingFunc: enclosingFunction(path, rng.Start, pkg.GetTypesInfo()), + enclosingFunc: enclosingFunction(path, pkg.GetTypesInfo()), enclosingCompositeLiteral: enclosingCompositeLiteral(path, rng.Start, pkg.GetTypesInfo()), opts: &completionOptions{ matcher: opts.Matcher, @@ -953,7 +953,7 @@ func (c *completer) lexical() error { } // Don't use LHS of value spec in RHS. - if vs := enclosingValueSpec(c.path, c.pos); vs != nil { + if vs := enclosingValueSpec(c.path); vs != nil { for _, ident := range vs.Names { if obj.Pos() == ident.Pos() { continue Names @@ -1263,7 +1263,7 @@ func enclosingCompositeLiteral(path []ast.Node, pos token.Pos, info *types.Info) // enclosingFunction returns the signature and body of the function // enclosing the given position. -func enclosingFunction(path []ast.Node, pos token.Pos, info *types.Info) *funcInfo { +func enclosingFunction(path []ast.Node, info *types.Info) *funcInfo { for _, node := range path { switch t := node.(type) { case *ast.FuncDecl: diff --git a/internal/lsp/source/completion_format.go b/internal/lsp/source/completion_format.go index 00b5ac3530..4e3afc87ca 100644 --- a/internal/lsp/source/completion_format.go +++ b/internal/lsp/source/completion_format.go @@ -67,7 +67,7 @@ func (c *completer) item(cand candidate) (CompletionItem, error) { detail = "struct{...}" // for anonymous structs } else if obj.IsField() { var err error - detail, err = formatFieldType(c.ctx, c.snapshot, c.pkg, obj, c.qf) + detail, err = formatFieldType(c.ctx, c.snapshot, c.pkg, obj) if err != nil { detail = types.TypeString(obj.Type(), c.qf) } diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go index eb6c86959b..dbf7529496 100644 --- a/internal/lsp/source/diagnostics.go +++ b/internal/lsp/source/diagnostics.go @@ -210,7 +210,7 @@ func diagnostics(ctx context.Context, snapshot Snapshot, reports map[FileIdentit } else if len(set.typeErrors) > 0 { hasTypeErrors = true } - if err := addReports(ctx, snapshot, reports, uri, diags...); err != nil { + if err := addReports(snapshot, reports, uri, diags...); err != nil { return false, false, err } } @@ -302,7 +302,7 @@ func analyses(ctx context.Context, snapshot Snapshot, reports map[FileIdentity][ if onlyDeletions(e.SuggestedFixes) { tags = append(tags, protocol.Unnecessary) } - if err := addReports(ctx, snapshot, reports, e.URI, &Diagnostic{ + if err := addReports(snapshot, reports, e.URI, &Diagnostic{ Range: e.Range, Message: e.Message, Source: e.Category, @@ -329,7 +329,7 @@ func clearReports(snapshot Snapshot, reports map[FileIdentity][]Diagnostic, uri return nil } -func addReports(ctx context.Context, snapshot Snapshot, reports map[FileIdentity][]Diagnostic, uri span.URI, diagnostics ...*Diagnostic) error { +func addReports(snapshot Snapshot, reports map[FileIdentity][]Diagnostic, uri span.URI, diagnostics ...*Diagnostic) error { if snapshot.View().Ignore(uri) { return nil } diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go index 643d599227..d55ed28ff4 100644 --- a/internal/lsp/source/format.go +++ b/internal/lsp/source/format.go @@ -36,7 +36,7 @@ func Format(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]protocol.T // Using format.Node on an AST with errors may result in code being modified. // Attempt to format the source of this file instead. if parseErrors != nil { - formatted, err := formatSource(ctx, snapshot, fh) + formatted, err := formatSource(ctx, fh) if err != nil { return nil, err } @@ -56,7 +56,7 @@ func Format(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]protocol.T return computeTextEdits(ctx, snapshot.View(), pgh.File(), m, buf.String()) } -func formatSource(ctx context.Context, s Snapshot, fh FileHandle) ([]byte, error) { +func formatSource(ctx context.Context, fh FileHandle) ([]byte, error) { ctx, done := event.StartSpan(ctx, "source.formatSource") defer done() diff --git a/internal/lsp/source/rename.go b/internal/lsp/source/rename.go index d47a604d48..6f79e26549 100644 --- a/internal/lsp/source/rename.go +++ b/internal/lsp/source/rename.go @@ -219,7 +219,7 @@ func (r *renamer) update() (map[span.URI][]diff.TextEdit, error) { // docComment returns the doc for an identifier. func (r *renamer) docComment(pkg Package, id *ast.Ident) *ast.CommentGroup { - _, nodes, _ := pathEnclosingInterval(r.ctx, r.fset, pkg, id.Pos(), id.End()) + _, nodes, _ := pathEnclosingInterval(r.fset, pkg, id.Pos(), id.End()) for _, node := range nodes { switch decl := node.(type) { case *ast.FuncDecl: @@ -250,7 +250,7 @@ func (r *renamer) docComment(pkg Package, id *ast.Ident) *ast.CommentGroup { func (r *renamer) updatePkgName(pkgName *types.PkgName) (*diff.TextEdit, error) { // Modify ImportSpec syntax to add or remove the Name as needed. pkg := r.packages[pkgName.Pkg()] - _, path, _ := pathEnclosingInterval(r.ctx, r.fset, pkg, pkgName.Pos(), pkgName.Pos()) + _, path, _ := pathEnclosingInterval(r.fset, pkg, pkgName.Pos(), pkgName.Pos()) if len(path) < 2 { return nil, errors.Errorf("no path enclosing interval for %s", pkgName.Name()) } diff --git a/internal/lsp/source/rename_check.go b/internal/lsp/source/rename_check.go index 44cc555454..8ff2879442 100644 --- a/internal/lsp/source/rename_check.go +++ b/internal/lsp/source/rename_check.go @@ -7,7 +7,6 @@ package source import ( - "context" "fmt" "go/ast" "go/token" @@ -193,7 +192,7 @@ func (r *renamer) checkInLexicalScope(from types.Object, pkg Package) { // Check for super-block conflict. // The name r.to is defined in a superblock. // Is that name referenced from within this block? - forEachLexicalRef(r.ctx, pkg, to, func(id *ast.Ident, block *types.Scope) bool { + forEachLexicalRef(pkg, to, func(id *ast.Ident, block *types.Scope) bool { _, obj := lexicalLookup(block, from.Name(), id.Pos()) if obj == from { // super-block conflict @@ -211,7 +210,7 @@ func (r *renamer) checkInLexicalScope(from types.Object, pkg Package) { // Check for sub-block conflict. // Is there an intervening definition of r.to between // the block defining 'from' and some reference to it? - forEachLexicalRef(r.ctx, pkg, from, func(id *ast.Ident, block *types.Scope) bool { + forEachLexicalRef(pkg, from, func(id *ast.Ident, block *types.Scope) bool { // Find the block that defines the found reference. // It may be an ancestor. fromBlock, _ := lexicalLookup(block, from.Name(), id.Pos()) @@ -283,7 +282,7 @@ func deeper(x, y *types.Scope) bool { // pkg that is a reference to obj in lexical scope. block is the // lexical block enclosing the reference. If fn returns false the // iteration is terminated and findLexicalRefs returns false. -func forEachLexicalRef(ctx context.Context, pkg Package, obj types.Object, fn func(id *ast.Ident, block *types.Scope) bool) bool { +func forEachLexicalRef(pkg Package, obj types.Object, fn func(id *ast.Ident, block *types.Scope) bool) bool { ok := true var stack []ast.Node @@ -386,7 +385,7 @@ func (r *renamer) checkStructField(from *types.Var) { // go/types offers no easy way to get from a field (or interface // method) to its declaring struct (or interface), so we must // ascend the AST. - pkg, path, _ := pathEnclosingInterval(r.ctx, r.fset, r.packages[from.Pkg()], from.Pos(), from.Pos()) + pkg, path, _ := pathEnclosingInterval(r.fset, r.packages[from.Pkg()], from.Pos(), from.Pos()) if pkg == nil || path == nil { return } @@ -842,7 +841,7 @@ func someUse(info *types.Info, obj types.Object) *ast.Ident { // // The zero value is returned if not found. // -func pathEnclosingInterval(ctx context.Context, fset *token.FileSet, pkg Package, start, end token.Pos) (resPkg Package, path []ast.Node, exact bool) { +func pathEnclosingInterval(fset *token.FileSet, pkg Package, start, end token.Pos) (resPkg Package, path []ast.Node, exact bool) { var pkgs = []Package{pkg} for _, f := range pkg.GetSyntax() { for _, imp := range f.Imports { diff --git a/internal/lsp/source/symbols.go b/internal/lsp/source/symbols.go index dff505d877..1a1624dece 100644 --- a/internal/lsp/source/symbols.go +++ b/internal/lsp/source/symbols.go @@ -36,7 +36,7 @@ func DocumentSymbols(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]p switch decl := decl.(type) { case *ast.FuncDecl: if obj := info.ObjectOf(decl.Name); obj != nil { - fs, err := funcSymbol(ctx, snapshot.View(), pkg, decl, obj, q) + fs, err := funcSymbol(snapshot.View(), pkg, decl, obj, q) if err != nil { return nil, err } @@ -52,7 +52,7 @@ func DocumentSymbols(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]p switch spec := spec.(type) { case *ast.TypeSpec: if obj := info.ObjectOf(spec.Name); obj != nil { - ts, err := typeSymbol(ctx, snapshot.View(), pkg, info, spec, obj, q) + ts, err := typeSymbol(snapshot.View(), pkg, info, spec, obj, q) if err != nil { return nil, err } @@ -62,7 +62,7 @@ func DocumentSymbols(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]p case *ast.ValueSpec: for _, name := range spec.Names { if obj := info.ObjectOf(name); obj != nil { - vs, err := varSymbol(ctx, snapshot.View(), pkg, decl, name, obj, q) + vs, err := varSymbol(snapshot.View(), pkg, decl, name, obj, q) if err != nil { return nil, err } @@ -76,7 +76,7 @@ func DocumentSymbols(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]p return symbols, nil } -func funcSymbol(ctx context.Context, view View, pkg Package, decl *ast.FuncDecl, obj types.Object, q types.Qualifier) (protocol.DocumentSymbol, error) { +func funcSymbol(view View, pkg Package, decl *ast.FuncDecl, obj types.Object, q types.Qualifier) (protocol.DocumentSymbol, error) { s := protocol.DocumentSymbol{ Name: obj.Name(), Kind: protocol.Function, @@ -112,7 +112,7 @@ func funcSymbol(ctx context.Context, view View, pkg Package, decl *ast.FuncDecl, return s, nil } -func typeSymbol(ctx context.Context, view View, pkg Package, info *types.Info, spec *ast.TypeSpec, obj types.Object, q types.Qualifier) (protocol.DocumentSymbol, error) { +func typeSymbol(view View, pkg Package, info *types.Info, spec *ast.TypeSpec, obj types.Object, q types.Qualifier) (protocol.DocumentSymbol, error) { s := protocol.DocumentSymbol{ Name: obj.Name(), } @@ -238,7 +238,7 @@ func nodesForStructField(i int, st *ast.StructType) (span, selection ast.Node) { return nil, nil } -func varSymbol(ctx context.Context, view View, pkg Package, decl ast.Node, name *ast.Ident, obj types.Object, q types.Qualifier) (protocol.DocumentSymbol, error) { +func varSymbol(view View, pkg Package, decl ast.Node, name *ast.Ident, obj types.Object, q types.Qualifier) (protocol.DocumentSymbol, error) { s := protocol.DocumentSymbol{ Name: obj.Name(), Kind: protocol.Variable, diff --git a/internal/lsp/source/util.go b/internal/lsp/source/util.go index 407169cda0..16fa1be0c0 100644 --- a/internal/lsp/source/util.go +++ b/internal/lsp/source/util.go @@ -458,7 +458,7 @@ func enclosingSelector(path []ast.Node, pos token.Pos) *ast.SelectorExpr { return nil } -func enclosingValueSpec(path []ast.Node, pos token.Pos) *ast.ValueSpec { +func enclosingValueSpec(path []ast.Node) *ast.ValueSpec { for _, n := range path { if vs, ok := n.(*ast.ValueSpec); ok { return vs @@ -504,7 +504,7 @@ func formatParams(ctx context.Context, s Snapshot, pkg Package, sig *types.Signa params := make([]string, 0, sig.Params().Len()) for i := 0; i < sig.Params().Len(); i++ { el := sig.Params().At(i) - typ, err := formatFieldType(ctx, s, pkg, el, qf) + typ, err := formatFieldType(ctx, s, pkg, el) if err != nil { typ = types.TypeString(el.Type(), qf) } @@ -523,7 +523,7 @@ func formatParams(ctx context.Context, s Snapshot, pkg Package, sig *types.Signa return params } -func formatFieldType(ctx context.Context, s Snapshot, srcpkg Package, obj types.Object, qf types.Qualifier) (string, error) { +func formatFieldType(ctx context.Context, s Snapshot, srcpkg Package, obj types.Object) (string, error) { file, pkg, err := findPosInPackage(s.View(), srcpkg, obj.Pos()) if err != nil { return "", err diff --git a/internal/lsp/tests/tests.go b/internal/lsp/tests/tests.go index efdff5957a..c4c483444b 100644 --- a/internal/lsp/tests/tests.go +++ b/internal/lsp/tests/tests.go @@ -1215,7 +1215,7 @@ func testFolders(root string) ([]string, error) { folders := []string{} root = filepath.FromSlash(root) // Get all test directories that are one level deeper than root. - if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + if err := filepath.Walk(root, func(path string, info os.FileInfo, _ error) error { if !info.IsDir() { return nil } diff --git a/internal/lsp/tests/util.go b/internal/lsp/tests/util.go index 924fbd550b..d6864d35db 100644 --- a/internal/lsp/tests/util.go +++ b/internal/lsp/tests/util.go @@ -66,18 +66,18 @@ func DiffSymbols(t *testing.T, uri span.URI, want, got []protocol.DocumentSymbol sort.Slice(want, func(i, j int) bool { return want[i].Name < want[j].Name }) sort.Slice(got, func(i, j int) bool { return got[i].Name < got[j].Name }) if len(got) != len(want) { - return summarizeSymbols(t, -1, want, got, "different lengths got %v want %v", len(got), len(want)) + return summarizeSymbols(-1, want, got, "different lengths got %v want %v", len(got), len(want)) } for i, w := range want { g := got[i] if w.Name != g.Name { - return summarizeSymbols(t, i, want, got, "incorrect name got %v want %v", g.Name, w.Name) + return summarizeSymbols(i, want, got, "incorrect name got %v want %v", g.Name, w.Name) } if w.Kind != g.Kind { - return summarizeSymbols(t, i, want, got, "incorrect kind got %v want %v", g.Kind, w.Kind) + return summarizeSymbols(i, want, got, "incorrect kind got %v want %v", g.Kind, w.Kind) } if protocol.CompareRange(w.SelectionRange, g.SelectionRange) != 0 { - return summarizeSymbols(t, i, want, got, "incorrect span got %v want %v", g.SelectionRange, w.SelectionRange) + return summarizeSymbols(i, want, got, "incorrect span got %v want %v", g.SelectionRange, w.SelectionRange) } if msg := DiffSymbols(t, uri, w.Children, g.Children); msg != "" { return fmt.Sprintf("children of %s: %s", w.Name, msg) @@ -86,7 +86,7 @@ func DiffSymbols(t *testing.T, uri span.URI, want, got []protocol.DocumentSymbol return "" } -func summarizeSymbols(t *testing.T, i int, want, got []protocol.DocumentSymbol, reason string, args ...interface{}) string { +func summarizeSymbols(i int, want, got []protocol.DocumentSymbol, reason string, args ...interface{}) string { msg := &bytes.Buffer{} fmt.Fprint(msg, "document symbols failed") if i >= 0 {