This test verifies the fix for golang/go#42301: renaming an ident inside its doc comment should also rename the ident. -- go.mod -- module example.com go 1.21 -- a/a.go -- package a // Foo doesn't do anything, Foo is just an empty function. //@rename(re"()Foo", "Bar", fooToBar), renameerr(re"()anything", "Bar", "no identifier found") func Foo() {} func _() { Foo() } -- b/b.go -- package b import "example.com/a" func _() { a.Foo() } -- c/c.go -- package c // A is an empty struct. //@rename(re"()A", "B", aToB) type A struct {} -- d/d.go -- package d // Bar doesn't do anything, Bar is just an empty function. //@rename(re", ()Bar", "Foo", barToFoo) func Bar() {} -- @aToB/c/c.go -- @@ -3,2 +3,2 @@ -// A is an empty struct. //@rename(re"()A", "B", aToB) -type A struct {} +// B is an empty struct. //@rename(re"()B", "B", aToB) +type B struct {} -- @barToFoo/d/d.go -- @@ -3,2 +3,2 @@ -// Bar doesn't do anything, Bar is just an empty function. //@rename(re", ()Bar", "Foo", barToFoo) -func Bar() {} +// Foo doesn't do anything, Foo is just an empty function. //@rename(re", ()Foo", "Foo", barToFoo) +func Foo() {} -- @fooToBar/a/a.go -- @@ -3,2 +3,2 @@ -// Foo doesn't do anything, Foo is just an empty function. //@rename(re"()Foo", "Bar", fooToBar), renameerr(re"()anything", "Bar", "no identifier found") -func Foo() {} +// Bar doesn't do anything, Bar is just an empty function. //@rename(re"()Bar", "Bar", fooToBar), renameerr(re"()anything", "Bar", "no identifier found") +func Bar() {} @@ -7 +7 @@ - Foo() + Bar() -- @fooToBar/b/b.go -- @@ -6 +6 @@ - a.Foo() + a.Bar()