diff --git a/gopls/internal/golang/codeaction.go b/gopls/internal/golang/codeaction.go index 0a778ba758b..85546d51537 100644 --- a/gopls/internal/golang/codeaction.go +++ b/gopls/internal/golang/codeaction.go @@ -333,9 +333,9 @@ func quickFix(ctx context.Context, req *codeActionsRequest) error { req.addApplyFixAction(msg, fixMissingCalledFunction, req.loc) } - // "undeclared name: x" or "undefined: x" compiler error. - // Offer a "Create variable/function x" code action. - // See [fixUndeclared] for command implementation. + // "undeclared name: X" or "undefined: X" compiler error. + // Offer a "Create variable/function X" code action. + // See [createUndeclared] for command implementation. case strings.HasPrefix(msg, "undeclared name: "), strings.HasPrefix(msg, "undefined: "): path, _ := astutil.PathEnclosingInterval(req.pgf.File, start, end) diff --git a/gopls/internal/golang/fix.go b/gopls/internal/golang/fix.go index f88343f029c..5300aa3fc2a 100644 --- a/gopls/internal/golang/fix.go +++ b/gopls/internal/golang/fix.go @@ -110,7 +110,7 @@ func ApplyFix(ctx context.Context, fix string, snapshot *cache.Snapshot, fh file fixInvertIfCondition: singleFile(invertIfCondition), fixSplitLines: singleFile(splitLines), fixJoinLines: singleFile(joinLines), - fixCreateUndeclared: singleFile(CreateUndeclared), + fixCreateUndeclared: singleFile(createUndeclared), fixMissingInterfaceMethods: stubMissingInterfaceMethodsFixer, fixMissingCalledFunction: stubMissingCalledFunctionFixer, } diff --git a/gopls/internal/golang/undeclared.go b/gopls/internal/golang/undeclared.go index 3d9954639b4..851c7b94c9e 100644 --- a/gopls/internal/golang/undeclared.go +++ b/gopls/internal/golang/undeclared.go @@ -69,8 +69,8 @@ func undeclaredFixTitle(path []ast.Node, errMsg string) string { return fmt.Sprintf("Create %s %s", noun, name) } -// CreateUndeclared generates a suggested declaration for an undeclared variable or function. -func CreateUndeclared(fset *token.FileSet, start, end token.Pos, content []byte, file *ast.File, pkg *types.Package, info *types.Info) (*token.FileSet, *analysis.SuggestedFix, error) { +// createUndeclared generates a suggested declaration for an undeclared variable or function. +func createUndeclared(fset *token.FileSet, start, end token.Pos, content []byte, file *ast.File, pkg *types.Package, info *types.Info) (*token.FileSet, *analysis.SuggestedFix, error) { pos := start // don't use the end path, _ := astutil.PathEnclosingInterval(file, pos, pos) if len(path) < 2 {