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
|
(In due course this bug will be fixed by moving certain
|
||||||
analyses into the type-checker.)
|
analyses into the type-checker.)
|
||||||
|
|
||||||
|
-dryrun causes the tool to report conflicts but not update any files.
|
||||||
|
|
||||||
-v enables verbose logging.
|
-v enables verbose logging.
|
||||||
|
|
||||||
gorename automatically computes the set of packages that might be
|
gorename automatically computes the set of packages that might be
|
||||||
|
|
@ -82,7 +84,7 @@ Examples:
|
||||||
|
|
||||||
% gorename -offset file.go:#123 -to foo
|
% 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
|
% gorename -from '(bytes.Buffer).Len' -to Size
|
||||||
|
|
||||||
|
|
@ -91,7 +93,6 @@ Examples:
|
||||||
---- TODO ----
|
---- TODO ----
|
||||||
|
|
||||||
Correctness:
|
Correctness:
|
||||||
- implement remaining safety checks.
|
|
||||||
- handle dot imports correctly
|
- handle dot imports correctly
|
||||||
- document limitations (reflection, 'implements' guesswork).
|
- document limitations (reflection, 'implements' guesswork).
|
||||||
- sketch a proof of exhaustiveness.
|
- sketch a proof of exhaustiveness.
|
||||||
|
|
@ -113,7 +114,7 @@ Features:
|
||||||
all local variables of a given type,
|
all local variables of a given type,
|
||||||
all PkgNames for a given package.
|
all PkgNames for a given package.
|
||||||
- emit JSON output for other editors and tools.
|
- emit JSON output for other editors and tools.
|
||||||
- integration support for editors other than Emacs.
|
- integration with editors other than Emacs.
|
||||||
`
|
`
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ var (
|
||||||
// It may even cause gorename to crash. TODO(adonovan): fix that.
|
// It may even cause gorename to crash. TODO(adonovan): fix that.
|
||||||
Force bool
|
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
|
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.)
|
// (It is distinguished because the interesting errors are the conflicts themselves.)
|
||||||
ConflictError = errors.New("renaming aborted due to conflicts")
|
ConflictError = errors.New("renaming aborted due to conflicts")
|
||||||
|
|
||||||
|
|
@ -280,7 +280,7 @@ func (r *renamer) update() error {
|
||||||
info.Pkg.Path())
|
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)
|
fmt.Fprintf(os.Stderr, "Error: %s.\n", err)
|
||||||
nerrs++
|
nerrs++
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +304,8 @@ func plural(n int) string {
|
||||||
return ""
|
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
|
// TODO(adonovan): print packages and filenames in a form useful
|
||||||
// to editors (so they can reload files).
|
// to editors (so they can reload files).
|
||||||
if Verbose {
|
if Verbose {
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,7 @@ var _ interface {f()} = C(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRewrites(t *testing.T) {
|
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 = savedRewriteFile
|
||||||
}(rewriteFile)
|
}(rewriteFile)
|
||||||
|
|
||||||
|
|
@ -654,7 +654,7 @@ func f(z interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
got := make(map[string]string)
|
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
|
var out bytes.Buffer
|
||||||
if err := format.Node(&out, fset, f); err != nil {
|
if err := format.Node(&out, fset, f); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue