Structural Search and Replace for throws List

hi!
i recently discovered SSR as a mighty tool to do bigger refactorings, i however i am struggling at understanding it fully.

i am trying to do the following: i have a ton of methods that are declared like

public void someMethod() throws MyException

myException is a runtime exception ans should be removed from the list.

i tried the following:

$ReturnType$ $MethodName$ ($ParameterType$ $Parameter$) throws $Ex$;

and i defined the parameters as 0..n and ex as 1..n with Ex matching the RuntimeException type.

however this does not work since idea says: this pattern is unsupported.

i only find result the following way:

class $anyclass$ {

$ReturnType$ $MethodName$ ($ParameterType$ $Parameter$) throws $Ex$;

}

but if i replace it with


class $anyclass$ {

$ReturnType$ $MethodName$ ($ParameterType$ $Parameter$);

}

all fields, method bodies an a lot more is lost..

do you have any general tip to improve my SSR learning curve? or any tips on this particular problem?
is there a good article somewhere for me to read?

0
2 comments
Avatar
Permanently deleted user

Hi,

For class level replacement you need custom variable that will receive
remaining class content (I have described this in article
http://www.jetbrains.com/idea/documentation/ssr.html)

Andreas P wrote:

hi!
i recently discovered SSR as a mighty tool to do bigger refactorings, i however i am struggling at understanding it fully.

i am trying to do the following: i have a ton of methods that are declared like

public void someMethod() throws MyException

myException is a runtime exception ans should be removed from the list.

i tried the following:

$ReturnType$ $MethodName$ ($ParameterType$ $Parameter$) throws $Ex$;

and i defined the parameters as 0..n and ex as 1..n with Ex matching the RuntimeException type.

however this does not work since idea says: this pattern is unsupported.

i only find result the following way:

class $anyclass$ {

$ReturnType$ $MethodName$ ($ParameterType$ $Parameter$) throws $Ex$;

}

but if i replace it with


class $anyclass$ {

$ReturnType$ $MethodName$ ($ParameterType$ $Parameter$);

}

all fields, method bodies an a lot more is lost..

do you have any general tip to improve my SSR learning curve? or any tips on this particular problem?
is there a good article somewhere for me to read?



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

thanks for that answer, unfortuanately i still have some problems, will post about it later

0

Please sign in to leave a comment.