Question about Structural Search and Replace

I want to change the definition of all classes in my project that extend a certain interface.

Let's say I want to change all classes that are defined like this:

public class MyClass implements MyInterface
to
class MyClass implements MyInterface

How can I do this using structural search and replace? I've tried using this pair for find/replace:

public class $NAME$ implements MyInterface
class $NAME$ implements MyInterface

What happens when I run this, though, is that the entire class definition is replaced by the latter term. How can I get this to do what I want?

Thanks,
Alex

2 comments

Never mind, I got it to work like this:

public class $NAME$ implements MyInterface {$STMT$}
class $NAME$ implements MyInterface {$STMT$}

With $STMT$'s max occurrences set to MaxIntValue. Was that the right way to do it? It seems awkward.

Also, is there an easier way to specify MaxIntValue than manually entering 2417-whatever in the "Maximum Occurrences" field?

0

I think that was the right way, but you should look into "Copy from existing
template" which I think would have given you a template that did this already.

I don't think there's a way to specify Integer.MAX_VALUE, but I think a value
of 10000 would be good for most things.

-Keith

Never mind, I got it to work like this:

public class $NAME$ implements MyInterface {$STMT$} class $NAME$
implements MyInterface {$STMT$}

With $STMT$'s max occurrences set to MaxIntValue. Was that the right
way to do it? It seems awkward.

Also, is there an easier way to specify MaxIntValue than manually
entering 2417-whatever in the "Maximum Occurrences" field?



0

Please sign in to leave a comment.