Skip to content

Commit

Permalink
change wording
Browse files Browse the repository at this point in the history
  • Loading branch information
xzbdmw committed Dec 5, 2024
1 parent 44670c7 commit 2f9c834
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions gopls/internal/golang/codeaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gopls/internal/golang/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions gopls/internal/golang/undeclared.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2f9c834

Please sign in to comment.