Structural Search & Replace Question

The structural search and replace I want to do is pretty trivial, but I'm obviously missing some key concept in ssr. I've read the excellent write-up at http://www.jetbrains.com/idea/documentation/ssr.html, but need more info.

The tag library & API in Ajax4JSF changed significantly from 3.3 to 4.0, partially to align with what changed in JSF from 1.2 to 2.0 . One of the changes, is that the "action" method (now the listener method) signature changed from this:

public void someMethod()

to this:

public void someMethod(javax.faces.event.AjaxBehaviorEvent)

So all I want to do is add an AjaxBehaviorEvent parm to existing methods. Fortunately, all of our action (aka listener) methods followed a common naming pattern, appending an "AjaxAction" suffix to the method name.

I copied a template that yielded the following:

class $Class$ {
  $ReturnType$ $MethodName$($ParameterType$ $Parameter$);
}


I then removed the parameter variables to get this:

class $Class$ {
  $ReturnType$ $MethodName$();
}


I set the $ReturnType$ variable to void. For the $MethodName$, I set the text to search for as .*AjaxAction. For $MethodName$, I checked the "This variable is the target of the search." To experiment with one class, I also specified a class' short name in the $Class$ variable, but in the general case I won't.

I changed the Replace field contents with this:

class $Class$ {
  $ReturnType$ $MethodName$(javax.faces.event.AjaxBehaviorEvent evt);
}


When doing the Search, the right class and right method are identified. However, the Replace wants to replace all of my class contents with just the newly modified method, because I obviously did that wrong. I  have no idea what trickery I need to employ to get the Replace to just replace the method signature of the one method matching the Find criteria.

So I have a couple of questions:

1) What should my Replace field look like to accomplish what I'm trying to do?

2) In this case, the method name sufficiently identifies the methods I'm looking for. However, in general, what would I do to find matching methods only in classes that have X as an ancestor? For example, all of our persistable classes have a public void save() method and have class Entity as an ancestor, but not necessarily as a direct super class. However, other classes also have a public void save() method. I want to find only the save methods on the Entity classes.

Thanks for any guidance on the Structural Search & Replace. I haven't used it much before, but really need it now.

jack

1 comment
Comment actions Permalink

I'm beginning to wonder if I was too detailed in my post. Here's the question in a nutshell:

How do I configure Structural Search and Replace to change all methods structured like this:

public void someMethodAjaxAction()

to this:

public void someMethodAjaxAction(javax.faces.event.AjaxBehaviorEvent)

Ideally, the search would only look for these methods in classes that have ParentClass in their inheritance hierarchy.

I hope this simpler format yields an answer.

Thanks in advance.

jack

0

Please sign in to leave a comment.