diff --git a/internal/lsp/source/completion/completion.go b/internal/lsp/source/completion/completion.go index 9f8f428fb6..bd157e6344 100644 --- a/internal/lsp/source/completion/completion.go +++ b/internal/lsp/source/completion/completion.go @@ -575,7 +575,7 @@ func (c *completer) collectCompletions(ctx context.Context) error { } if lt := c.wantLabelCompletion(); lt != labelNone { - c.labels(ctx, lt) + c.labels(lt) return nil } @@ -1065,7 +1065,7 @@ func (c *completer) selector(ctx context.Context, sel *ast.SelectorExpr) error { // Is sel a qualified identifier? if id, ok := sel.X.(*ast.Ident); ok { if pkgName, ok := c.pkg.GetTypesInfo().Uses[id].(*types.PkgName); ok { - candidates := c.packageMembers(ctx, pkgName.Imported(), stdScore, nil) + candidates := c.packageMembers(pkgName.Imported(), stdScore, nil) for _, cand := range candidates { c.deepState.enqueue(cand) } @@ -1076,7 +1076,7 @@ func (c *completer) selector(ctx context.Context, sel *ast.SelectorExpr) error { // Invariant: sel is a true selector. tv, ok := c.pkg.GetTypesInfo().Types[sel.X] if ok { - candidates := c.methodsAndFields(ctx, tv.Type, tv.Addressable(), nil) + candidates := c.methodsAndFields(tv.Type, tv.Addressable(), nil) for _, cand := range candidates { c.deepState.enqueue(cand) } @@ -1133,7 +1133,7 @@ func (c *completer) unimportedMembers(ctx context.Context, id *ast.Ident) error if imports.ImportPathToAssumedName(path) != pkg.GetTypes().Name() { imp.name = pkg.GetTypes().Name() } - candidates := c.packageMembers(ctx, pkg.GetTypes(), unimportedScore(relevances[path]), imp) + candidates := c.packageMembers(pkg.GetTypes(), unimportedScore(relevances[path]), imp) for _, cand := range candidates { c.deepState.enqueue(cand) } @@ -1183,7 +1183,7 @@ func unimportedScore(relevance int) float64 { return (stdScore + .1*float64(relevance)) / 2 } -func (c *completer) packageMembers(ctx context.Context, pkg *types.Package, score float64, imp *importInfo) []candidate { +func (c *completer) packageMembers(pkg *types.Package, score float64, imp *importInfo) []candidate { var candidates []candidate scope := pkg.Scope() for _, name := range scope.Names() { @@ -1198,7 +1198,7 @@ func (c *completer) packageMembers(ctx context.Context, pkg *types.Package, scor return candidates } -func (c *completer) methodsAndFields(ctx context.Context, typ types.Type, addressable bool, imp *importInfo) []candidate { +func (c *completer) methodsAndFields(typ types.Type, addressable bool, imp *importInfo) []candidate { mset := c.methodSetCache[methodSetKey{typ, addressable}] if mset == nil { if addressable && !types.IsInterface(typ) && !isPointer(typ) { diff --git a/internal/lsp/source/completion/completion_format.go b/internal/lsp/source/completion/completion_format.go index 6f18e51f17..9549f87c17 100644 --- a/internal/lsp/source/completion/completion_format.go +++ b/internal/lsp/source/completion/completion_format.go @@ -104,7 +104,7 @@ func (c *completer) item(ctx context.Context, cand candidate) (CompletionItem, e // If this candidate needs an additional import statement, // add the additional text edits needed. if cand.imp != nil { - addlEdits, err := c.importEdits(ctx, cand.imp) + addlEdits, err := c.importEdits(cand.imp) if err != nil { return CompletionItem{}, err } @@ -211,7 +211,7 @@ func (c *completer) item(ctx context.Context, cand candidate) (CompletionItem, e } // importEdits produces the text edits necessary to add the given import to the current file. -func (c *completer) importEdits(ctx context.Context, imp *importInfo) ([]protocol.TextEdit, error) { +func (c *completer) importEdits(imp *importInfo) ([]protocol.TextEdit, error) { if imp == nil { return nil, nil } @@ -221,7 +221,7 @@ func (c *completer) importEdits(ctx context.Context, imp *importInfo) ([]protoco return nil, err } - return source.ComputeOneImportFixEdits(ctx, c.snapshot, pgf, &imports.ImportFix{ + return source.ComputeOneImportFixEdits(c.snapshot, pgf, &imports.ImportFix{ StmtInfo: imports.ImportInfo{ ImportPath: imp.importPath, Name: imp.name, diff --git a/internal/lsp/source/completion/completion_labels.go b/internal/lsp/source/completion/completion_labels.go index 2d4bdb9a82..e4fd961e31 100644 --- a/internal/lsp/source/completion/completion_labels.go +++ b/internal/lsp/source/completion/completion_labels.go @@ -5,7 +5,6 @@ package completion import ( - "context" "go/ast" "go/token" "math" @@ -50,7 +49,7 @@ func takesLabel(n ast.Node) labelType { // labels adds completion items for labels defined in the enclosing // function. -func (c *completer) labels(ctx context.Context, lt labelType) { +func (c *completer) labels(lt labelType) { if c.enclosingFunc == nil { return } diff --git a/internal/lsp/source/completion/completion_literal.go b/internal/lsp/source/completion/completion_literal.go index 7582e57ad7..e7ebc6e087 100644 --- a/internal/lsp/source/completion/completion_literal.go +++ b/internal/lsp/source/completion/completion_literal.go @@ -98,7 +98,7 @@ func (c *completer) literal(ctx context.Context, literalType types.Type, imp *im matchName = types.TypeString(t.Elem(), qf) } - addlEdits, err := c.importEdits(ctx, imp) + addlEdits, err := c.importEdits(imp) if err != nil { event.Error(ctx, "error adding import for literal candidate", err) return diff --git a/internal/lsp/source/completion/completion_package.go b/internal/lsp/source/completion/completion_package.go index f9d30d5109..f8d3431da2 100644 --- a/internal/lsp/source/completion/completion_package.go +++ b/internal/lsp/source/completion/completion_package.go @@ -41,7 +41,7 @@ func packageClauseCompletions(ctx context.Context, snapshot source.Snapshot, fh return nil, nil, err } - surrounding, err := packageCompletionSurrounding(ctx, snapshot.FileSet(), fh, pgf, rng.Start) + surrounding, err := packageCompletionSurrounding(snapshot.FileSet(), fh, pgf, rng.Start) if err != nil { return nil, nil, errors.Errorf("invalid position for package completion: %w", err) } @@ -68,7 +68,7 @@ func packageClauseCompletions(ctx context.Context, snapshot source.Snapshot, fh // packageCompletionSurrounding returns surrounding for package completion if a // package completions can be suggested at a given position. A valid location // for package completion is above any declarations or import statements. -func packageCompletionSurrounding(ctx context.Context, fset *token.FileSet, fh source.FileHandle, pgf *source.ParsedGoFile, pos token.Pos) (*Selection, error) { +func packageCompletionSurrounding(fset *token.FileSet, fh source.FileHandle, pgf *source.ParsedGoFile, pos token.Pos) (*Selection, error) { src, err := fh.Read() if err != nil { return nil, err diff --git a/internal/lsp/source/completion/deep_completion.go b/internal/lsp/source/completion/deep_completion.go index ec485f2cf7..da8c117e1d 100644 --- a/internal/lsp/source/completion/deep_completion.go +++ b/internal/lsp/source/completion/deep_completion.go @@ -196,7 +196,7 @@ outer: if sig.Params().Len() == 0 && sig.Results().Len() == 1 { path, names := c.deepState.newPath(cand, obj, true) // The result of a function call is not addressable. - candidates := c.methodsAndFields(ctx, sig.Results().At(0).Type(), false, cand.imp) + candidates := c.methodsAndFields(sig.Results().At(0).Type(), false, cand.imp) for _, newCand := range candidates { newCand.path, newCand.names = path, names c.deepState.enqueue(newCand) @@ -207,13 +207,13 @@ outer: path, names := c.deepState.newPath(cand, obj, false) switch obj := obj.(type) { case *types.PkgName: - candidates := c.packageMembers(ctx, obj.Imported(), stdScore, cand.imp) + candidates := c.packageMembers(obj.Imported(), stdScore, cand.imp) for _, newCand := range candidates { newCand.path, newCand.names = path, names c.deepState.enqueue(newCand) } default: - candidates := c.methodsAndFields(ctx, obj.Type(), cand.addressable, cand.imp) + candidates := c.methodsAndFields(obj.Type(), cand.addressable, cand.imp) for _, newCand := range candidates { newCand.path, newCand.names = path, names c.deepState.enqueue(newCand) diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go index bd669b40a2..5d25d187b3 100644 --- a/internal/lsp/source/format.go +++ b/internal/lsp/source/format.go @@ -134,7 +134,7 @@ func computeImportEdits(ctx context.Context, snapshot Snapshot, pgf *ParsedGoFil } // ComputeOneImportFixEdits returns text edits for a single import fix. -func ComputeOneImportFixEdits(ctx context.Context, snapshot Snapshot, pgf *ParsedGoFile, fix *imports.ImportFix) ([]protocol.TextEdit, error) { +func ComputeOneImportFixEdits(snapshot Snapshot, pgf *ParsedGoFile, fix *imports.ImportFix) ([]protocol.TextEdit, error) { options := &imports.Options{ LocalPrefix: snapshot.View().Options().Local, // Defaults.