Reputation: 5247
Lets say I want to replace print(x)
with print(wrapper(x))
. I can match
print($Argument$)
and replace it with
print(wrapper($Argument$))
However, if I already have a call to print(wrapper(x))
, I don't want to replace that with print(wrapper(wrapper(x)))
. How can I avoid that? In other words, how do I say "do the replacement, unless the arguments match some pattern"?
Upvotes: 0
Views: 365
Reputation: 377
Another option is to replace
print($Argument$)
with
print(wrapper($Argument$))
and then get rid of any double wrappers by replacing
print(wrapper(wrapper($Argument$)))
with
print(wrapper($Argument$))
Upvotes: 0
Reputation: 51441
You would:
System.out.println($args$)
Edit Variables
$args$
variableText constraints -> Text/regexp
enter ^wrapper\(.*\)$
and tick Invert condition
Obviously you can tweak that regex to whatever you want. Invert condition means that the search will skip all instances where condition is met. Basically you write a regex to match what you don’t want to see and Invert condition
is a NOT
operator.
On my test text:
System.out.println( ex.getMessage() );
System.out.println( wrapper( ex.getMessage() ) );
The second instance was not in the search results.
Upvotes: 1