Structural search question

I'm working on some unit tests that were written like this

public void testXXX() {
try {
// some code
System.out.println("test is ok XXX");
} catch (Exception e) {"XXX message");

I thought It would be possible to do structural search & replace.

I managed to craft a search query that seems to do what I want
class $CLASS$  {
    void $Method$() {
    try {
    } catch($SomeException$ $ExceptionDcl$) {$message$);

$Method$ unlimited
$OtherStatements$ unlimited

But if I use that for a replace, the whole class gets replaced, not just the method.

Is there a way to do it ?

Please sign in to leave a comment.