I want to delete an exception that should have never existed. I can not find the pattern that allows the deletion in the method declarations.
This code :
public void method1(String param) throws ShouldHaveNeverExisted{
System.out.println("Yo");
//...
}
public void method2WithoutParam() throws ShouldHaveNeverExisted{
System.out.println("Yo");
//...
}
Should be transform in :
public void method1(String param){
System.out.println("Yo");
//...
}
public void method2WithoutParam(){
System.out.println("Yo");
//...
}
The following pattern retrieve what I want but I can't find the correct replacement pattern.
class $Class$ {
$ReturnType$ $MethodName$($ParameterType$ $Parameter$) throws ShouldHaveNeverExisted;
}
Search pattern:
Replacement pattern:
The main caveat is to "Edit variables" and turn on "This variable is target of the search" checkbox for
$Method$
variable (on every try, unfortunately). Also$SomeStatement$
's max count must be unlimited.Then IDEA 11.0.1 does search correctly. Even for any order of exceptions in
throws
clause. And it even shows correct result on "Preview Replacement" button click. But then actually just deletes methods found. :(This seems to be a bug. Please, someone confirm.
BTW. If you're getting rid of this exception anywhere, why not just replace "throws ShouldHaveNeverExisted" with "" with regular "Edit\Find\Replace in Path Ctrl+Shift+R"?
Or you could just hit Del on exception's class and check "Safe delete (with usage search)".