Giter Club home page Giter Club logo

Comments (8)

mkleina avatar mkleina commented on May 28, 2024 1

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.

from gorename.

alvarolm avatar alvarolm commented on May 28, 2024

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

from gorename.

alvarolm avatar alvarolm commented on May 28, 2024

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

from gorename.

alvarolm avatar alvarolm commented on May 28, 2024

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

from gorename.

mkleina avatar mkleina commented on May 28, 2024

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'

from gorename.

mkleina avatar mkleina commented on May 28, 2024

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.

from gorename.

alvarolm avatar alvarolm commented on May 28, 2024

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'

from gorename.

alvarolm avatar alvarolm commented on May 28, 2024

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

from gorename.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.