SSR: Replacing setters with builder type setters
I'd like to do a search and replace that finds all setters in the class (which return void) and replaces them with setters that return this object... (this allows chaining of setter invocations)...
I can use the following SSR to find method calls:
class $Class$ {
$ReturnType$ $MethodName$($ParameterType$ $Parameter$) {
$stmt$;
}
}
Other settings
$MethodName$ I use the regexp naming constraint set.*
$ReturnType$ I specify void as the text constraint.
$stmt$ occurrence count set 0 to unlimited
If set the $MethodName$ var as the target of the search, I can find all setters successfully. However, when I tried to use the following replacement pattern, IntelliJ is not able to effect the replacement
class $Class$ {
$Class$ $MethodName$($ParameterType$ $Parameter$) {
$stmt$;
return this;
}
}
Has anyone been able to succesfully do a replacement like this using SSR before? How?
Let me know if a JIRA should be opened for this.
Please sign in to leave a comment.