mirror of
https://github.com/golang/go
synced 2024-11-18 11:34:45 -07:00
refactor: minor no-op fixes
- fix typos and mistakes in docstrings, usage message and comments. - remove 'backup' parameter to rewriteFile LGTM=sameer R=sameer CC=golang-codereviews https://golang.org/cl/147980043
This commit is contained in:
parent
f123f00fbc
commit
e94ae77171
@ -64,6 +64,8 @@ Flags:
|
||||
(In due course this bug will be fixed by moving certain
|
||||
analyses into the type-checker.)
|
||||
|
||||
-dryrun causes the tool to report conflicts but not update any files.
|
||||
|
||||
-v enables verbose logging.
|
||||
|
||||
gorename automatically computes the set of packages that might be
|
||||
@ -82,7 +84,7 @@ Examples:
|
||||
|
||||
% gorename -offset file.go:#123 -to foo
|
||||
|
||||
Rename the object whose identifer is at byte offset 123 within file file.go.
|
||||
Rename the object whose identifier is at byte offset 123 within file file.go.
|
||||
|
||||
% gorename -from '(bytes.Buffer).Len' -to Size
|
||||
|
||||
@ -91,7 +93,6 @@ Examples:
|
||||
---- TODO ----
|
||||
|
||||
Correctness:
|
||||
- implement remaining safety checks.
|
||||
- handle dot imports correctly
|
||||
- document limitations (reflection, 'implements' guesswork).
|
||||
- sketch a proof of exhaustiveness.
|
||||
@ -113,7 +114,7 @@ Features:
|
||||
all local variables of a given type,
|
||||
all PkgNames for a given package.
|
||||
- emit JSON output for other editors and tools.
|
||||
- integration support for editors other than Emacs.
|
||||
- integration with editors other than Emacs.
|
||||
`
|
||||
|
||||
func main() {
|
||||
|
@ -32,10 +32,10 @@ var (
|
||||
// It may even cause gorename to crash. TODO(adonovan): fix that.
|
||||
Force bool
|
||||
|
||||
// DryRun causes the patch to be displayed but not applied.
|
||||
// DryRun causes the tool to report conflicts but not update any files.
|
||||
DryRun bool
|
||||
|
||||
// ConfictError is returned by Main when it aborts the renaming due to conflicts.
|
||||
// ConflictError is returned by Main when it aborts the renaming due to conflicts.
|
||||
// (It is distinguished because the interesting errors are the conflicts themselves.)
|
||||
ConflictError = errors.New("renaming aborted due to conflicts")
|
||||
|
||||
@ -280,7 +280,7 @@ func (r *renamer) update() error {
|
||||
info.Pkg.Path())
|
||||
}
|
||||
}
|
||||
if err := rewriteFile(r.iprog.Fset, f, tokenFile.Name(), tokenFile.Name()+".prename"); err != nil {
|
||||
if err := rewriteFile(r.iprog.Fset, f, tokenFile.Name()); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s.\n", err)
|
||||
nerrs++
|
||||
}
|
||||
@ -304,7 +304,8 @@ func plural(n int) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
var rewriteFile = func(fset *token.FileSet, f *ast.File, orig, backup string) (err error) {
|
||||
var rewriteFile = func(fset *token.FileSet, f *ast.File, orig string) (err error) {
|
||||
backup := orig + ".prename"
|
||||
// TODO(adonovan): print packages and filenames in a form useful
|
||||
// to editors (so they can reload files).
|
||||
if Verbose {
|
||||
|
@ -372,7 +372,7 @@ var _ interface {f()} = C(0)
|
||||
}
|
||||
|
||||
func TestRewrites(t *testing.T) {
|
||||
defer func(savedRewriteFile func(*token.FileSet, *ast.File, string, string) error) {
|
||||
defer func(savedRewriteFile func(*token.FileSet, *ast.File, string) error) {
|
||||
rewriteFile = savedRewriteFile
|
||||
}(rewriteFile)
|
||||
|
||||
@ -654,7 +654,7 @@ func f(z interface{}) {
|
||||
}
|
||||
|
||||
got := make(map[string]string)
|
||||
rewriteFile = func(fset *token.FileSet, f *ast.File, orig, backup string) error {
|
||||
rewriteFile = func(fset *token.FileSet, f *ast.File, orig string) error {
|
||||
var out bytes.Buffer
|
||||
if err := format.Node(&out, fset, f); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user