jedediah jedediah - 1 month ago 21
Java Question

Replace superclass using IDEA SSR

I want to search for all classes extending

Foo
and make them extend
Bar
instead. The IDEA manual says this should work:

Search template

class $Class$ extends Foo {
$Stuff$
}


Replace template

class $Class$ extends Bar {
$Stuff$
}


where
$Stuff$
is configured to match zero to infinity times.

The search part works fine, but the replacement always has an empty class body. I tried setting
$Stuff$
's minimum count to 1 and that still matches all the right classes, but the class body is still empty.

Answer

It should be

Search Template

class $Class$ extends Foo {}

Replace Template

class $Class$ extends Bar {}

No need to add $Stuff$.

You can find the examples documentation here.