I'm creating own inspections based on Structural Replace. For example I want to make inspection of transforming code like:
if (!$Map$.containsKey($key$)){
$Map$.put($key$, $value$);
}
and
if ($Map$.get($key$) == null){
$Map$.put($key$, $value$);
}
into
$Map$.putIfAbsent($key$, $value$);
But I don't want it to react on code like:
if (!$Map$.containsKey($key$)){
$Map$.put($key$, $value$);
}
else {
// any logic
}
I tried to use
if (!$Map$.containsKey($key$)){
$Map$.put($key$, $value$);
}
$else$
with option text "else" but it didn't work.
Is it possible? Also I have to make two different inspections with same replace result. Can we use multiple searh pattern?
UPDATE:
I tried replace next pattern
$Iterable$.forEach($value$ -> {
if ($condition$) {
$statement$;
}
});
into
$Iterable$.stream()
.filter($value$ -> $condition$)
.forEach($value$ -> $statement$);
But after replace I'm getting:
$Iterable$.stream()
.filter($value$ -> $condition$)
.forEach($value$ -> $statement$;);
Is it possible to remove ";" from replace result?