Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid GoRename parameters" #5

Closed
mkleina opened this issue May 24, 2016 · 8 comments
Closed

"Invalid GoRename parameters" #5

mkleina opened this issue May 24, 2016 · 8 comments

Comments

@mkleina
Copy link
Contributor

mkleina commented May 24, 2016

I have gorename tool installed, it works great it Atom editor. When I press Ctrl+Alt+R, ESC, then type new variable name and press Enter, console shows part of code and "Press ENTER to continue" message. After pressing Enter again, console shows "gorename: surplus arguments" message and "Invalid GoRename parameters" popup appears. Code is not modified after that, so plugin doesn't work at all for me. I am using Ubuntu 16.04 and Sublime Text 3 build 3103.

@alvarolm
Copy link
Owner

make sure that when yout type the new variable name there's no more than one word.

@alvarolm
Copy link
Owner

alvarolm commented May 24, 2016

I wasn't able to reproduce this btw, please make sure you have the latest version.

@alvarolm alvarolm changed the title Plugin doesn't work, message "Invalid GoRename parameters" "Invalid GoRename parameters" May 24, 2016
@alvarolm
Copy link
Owner

its seems there is a some weird first time running behavior, after installation try restarting sublime.

@mkleina
Copy link
Contributor Author

mkleina commented May 24, 2016

I restarted Sublime several times, every time I'm typing single-word variable. Plugin was installed today from Package Control package manager. There are also some errors when I look at Sublime console:

Package Control: Skipping automatic upgrade, last run at 2016-05-24 17:55:43, next run at 2016-05-24 18:55:43 or after
error: Invalid GoRename parameters
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 574, in run_
    return self.run(edit)
  File "goRename in /home/mkleina/.config/sublime-text-3/Installed Packages/GoRename.sublime-package", line 317, in run
KeyError: 'file_path'
Unable to fetch update url contents
error: Invalid GoRename parameters
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 574, in run_
    return self.run(edit)
  File "goRename in /home/mkleina/.config/sublime-text-3/Installed Packages/GoRename.sublime-package", line 317, in run
KeyError: 'file_path'

@mkleina
Copy link
Contributor Author

mkleina commented May 24, 2016

It is some problem with args passing to gorename tool for sure, but I can't see any logs what the plugin really trying to launch. To reproduce the same message just type in console:

$ gorename non-existing-argument
gorename: surplus arguments

This is my gorename --help output:

gorename: precise type-safe renaming of identifiers in Go source code.

Usage:

 gorename (-from <spec> | -offset <file>:#<byte-offset>) -to <name> [-force]

You must specify the object (named entity) to rename using the -offset
or -from flag.  Exactly one must be specified.

Flags:

-offset    specifies the filename and byte offset of an identifier to rename.
           This form is intended for use by text editors.

-from      specifies the object to rename using a query notation;
           This form is intended for interactive use at the command line.
           A legal -from query has one of the following forms:

  "encoding/json".Decoder.Decode        method of package-level named type
  (*"encoding/json".Decoder).Decode     ditto, alternative syntax
  "encoding/json".Decoder.buf           field of package-level named struct type
  "encoding/json".HTMLEscape            package member (const, func, var, type)
  "encoding/json".Decoder.Decode::x     local object x within a method
  "encoding/json".HTMLEscape::x         local object x within a function
  "encoding/json"::x                    object x anywhere within a package
  json.go::x                            object x within file json.go

           Double-quotes must be escaped when writing a shell command.
           Quotes may be omitted for single-segment import paths such as "fmt".

           For methods, the parens and '*' on the receiver type are both
           optional.

           It is an error if one of the ::x queries matches multiple
           objects.

-to        the new name.

-force     causes the renaming to proceed even if conflicts were reported.
           The resulting program may be ill-formed, or experience a change
           in behaviour.

           WARNING: this flag may even cause the renaming tool to crash.
           (In due course this bug will be fixed by moving certain
           analyses into the type-checker.)

-d         display diffs instead of rewriting files

-v         enables verbose logging.

gorename automatically computes the set of packages that might be
affected.  For a local renaming, this is just the package specified by
-from or -offset, but for a potentially exported name, gorename scans
the workspace ($GOROOT and $GOPATH).

gorename rejects renamings of concrete methods that would change the
assignability relation between types and interfaces.  If the interface
change was intentional, initiate the renaming at the interface method.

gorename rejects any renaming that would create a conflict at the point
of declaration, or a reference conflict (ambiguity or shadowing), or
anything else that could cause the resulting program not to compile.


Examples:

$ gorename -offset file.go:#123 -to foo

  Rename the object whose identifier is at byte offset 123 within file file.go.

$ gorename -from '"bytes".Buffer.Len' -to Size

  Rename the "Len" method of the *bytes.Buffer type to "Size".

---- TODO ----

Correctness:
- handle dot imports correctly
- document limitations (reflection, 'implements' algorithm).
- sketch a proof of exhaustiveness.

Features:
- support running on packages specified as *.go files on the command line
- support running on programs containing errors (loader.Config.AllowErrors)
- allow users to specify a scope other than "global" (to avoid being
  stuck by neglected packages in $GOPATH that don't build).
- support renaming the package clause (no object)
- support renaming an import path (no ident or object)
  (requires filesystem + SCM updates).
- detect and reject edits to autogenerated files (cgo, protobufs)
  and optionally $GOROOT packages.
- report all conflicts, or at least all qualitatively distinct ones.
  Sometimes we stop to avoid redundancy, but
  it may give a disproportionate sense of safety in -force mode.
- support renaming all instances of a pattern, e.g.
  all receiver vars of a given type,
  all local variables of a given type,
  all PkgNames for a given package.
- emit JSON output for other editors and tools.

@alvarolm
Copy link
Owner

the debug logs would be very useful, to enable them go to
Preferences > Package Settings > GoRename > Settings - User
and set gorename_debug to true then restart and copy paste the lines from the console that start with 'GoRename'

@mkleina
Copy link
Contributor Author

mkleina commented May 25, 2016

I found the issue - plugin does not support spaces in file path. For example:

GoRename [DEBUG]: ('cmd', 'gorename -offset /home/mkleina/work/src/github.com/intelsdi-x/my proj/test.go:#682 -to abc')

When I try to run this in terminal:

$ gorename -offset /home/mkleina/work/src/github.com/intelsdi-x/my proj/test.go:#682 -to abc
gorename: surplus arguments

As soon as I renamed "my proj" to "my_proj" everything worked great. I never use spaces in directory names, but I was using symlink, which was automatically named "Link to blahblah" and that was the problem.

The gorename tool does not support quotation marks for file path, but it is possible to resolve this by escaping space character. I was able to do this in terminal without any problem:

$ gorename -offset /home/mkleina/work/src/github.com/intelsdi-x/my\ proj/test.go:#682 -to abc
Renamed 2 occurrences in 1 file in 1 package.

@alvarolm
Copy link
Owner

thanks mkleina !

Any contributions to fix this issue are welcome, currently I don't have the time, somehow the solution should be fairly trivial now that we are aware of the specifics.
#6

@alvarolm alvarolm closed this as completed Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants