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

x/tools/cmd/gorename: update comments associated with renamed symbol #17994

Closed
dbenque opened this issue Nov 20, 2016 · 3 comments
Closed

x/tools/cmd/gorename: update comments associated with renamed symbol #17994

dbenque opened this issue Nov 20, 2016 · 3 comments

Comments

@dbenque
Copy link

@dbenque dbenque commented Nov 20, 2016

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.7 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"

What did you do?

gorename tool does not update the comment associated to the renamed symbol. As comment are used for documentation and are validated by go linter, refactoring the code with gorename often let the code in something that compile but that dose not follow the rules for comments.

let's consider the following program:

package main

// MyFunc documenation
func MyFunc() {}

func main() {
        MyFunc()
}

If we rename 'MyFunc' the associated comment will not be update:

> gorename -from "test.MyFunc" -to "NewFunc" -d

@@ -1,8 +1,8 @@
 package pkg
 
 // MyFunc documenation
-func MyFunc() {}
+func NewFunc() {}
 
 func main() {
-       MyFunc()
+       NewFunc()
 }

What did you expect to see? What I would like to see?

Would be good if gorename can also take care of updating the comments:

@@ -1,8 +1,8 @@
 package pkg
 
-// MyFunc documenation
-func MyFunc() {}
+// NewFunc documenation
+func NewFunc() {}
 
 func main() {
-       MyFunc()
+       NewFunc()
 }
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 20, 2016

CL https://golang.org/cl/33394 mentions this issue.

@gopherbot
Copy link

@gopherbot gopherbot commented Nov 22, 2016

CL https://golang.org/cl/33452 mentions this issue.

@quentinmit quentinmit added the NeedsFix label Nov 22, 2016
@quentinmit quentinmit added this to the Unreleased milestone Nov 22, 2016
@quentinmit quentinmit changed the title gorename not updating comments associated to renamed symbol. x/tools/cmd/gorename: update comments associated with renamed symbol Nov 22, 2016
@dbenque
Copy link
Author

@dbenque dbenque commented Nov 22, 2016

@quentinmit thanks for your code. I did not know about the "PathEnclosingInterval(pos, pos)" function, it clearly makes a better code that what I initially proposed.

@golang golang locked and limited conversation to collaborators Nov 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.