Need help with Structural Replace: renaming methods

Perhaps it is a simple thing, but I cannot figure out how to do it.
I want to use SR, not "rename method", because there lots and lots of methods (the same pattern).
I can do structural search for these methods fine, but the problem is with replace.

What I want is to rename all method declarations ending with "Foo".
So the pattern is:

class $Class$ {
$before$
$ReturnType$ $MethodName$() {$s$;}
$after$
}


->

class $Class$ {
$before$
$ReturnType$ $NewMethodName$() {$s$;}
$after$
}



$before$, $after$, $s$ are [0, +inf], MethodName has constraint ".+Foo" + "this is the target"
So, search works as expected.

For replace - there is no doc for "Groovy script", and I put there this:

binding.variables.MethodName.text + "Suffix"

Supposedly, it should append "Suffix" to method names.

When I run it, I set "this is the target" on MethodName var (it always disappears when editing variables).
Then I get the proper list of results, but "Preview" and "Replace" does nothing!

When I run the same replace, but without setting target variable, the class becomes the target. Buttons "Replace" work... but the replace the whole class with the method!

Can anyone suggest how to do that?

Thanks.

0

请先登录再写评论。