Trying to create a custom inspection where the regex of one variable includes another variable
Answered
I'm creating a custom inspection. I've found the dialog where I can create a Replace template and all that. My ultimate goal is to create an inspection that shows a warning when a getter or setter method includes the Class or Superclass name within the method name. I copied this existing template,
class $_1$ {
$ReturnType$ $Method$ ($ParameterType$ $Parameter$);
}
I edited $Method$ so that it matches the regex get[\w]*$_1$[\w]*|get[\w]*$_1$[\w]* This does not match methods that begin with get or set and also include the class or superclass name, as I would like. I think the issue is in it not matching $_1$, which I guess I cannot use in a regex. Any suggestions? Thanks.
Please sign in to leave a comment.
You can achieve your goal by using a Script constraint. To start I would base this on the "methods of the class" existing template:
Now edit $method$ to match Text/regexp
And add a Script constraint like:
This is a little complicated but should get you the result you want.
Bas