结构替换删除异常
我想删除一个不应该存在的异常。我找不到允许在方法声明中删除的模式。
此代码:
public void method1(String param) throws ShouldHaveNeverExisted{
System.out.println("Yo");
//...
}
public void method2WithoutParam() throws ShouldHaveNeverExisted{
System.out.println("Yo");
//...
}
应该转换为:
public void method1(String param){
System.out.println("Yo");
//...
}
public void method2WithoutParam(){
System.out.println("Yo");
//...
}
以下模式检索我想要的内容,但我找不到正确的替换模式。
class $Class$ {
$ReturnType$ $MethodName$($ParameterType$ $Parameter$) throws ShouldHaveNeverExisted;
}
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
搜索模式:
替换模式:
主要注意事项是“编辑变量”并打开
$Method$
变量的“此变量是搜索目标”复选框(每次尝试时,不幸的是)。此外,$SomeStatement$
的最大计数必须不受限制。然后 IDEA 11.0.1 确实可以正确搜索。即使对于
throws
子句中的任何顺序的异常也是如此。它甚至在单击“预览替换”按钮时显示正确的结果。但实际上只是删除找到的方法。 :(
这似乎是一个错误。请有人确认。
顺便说一句。如果您要在任何地方摆脱此异常,为什么不直接将“throws ShouldHaveNeverExisted”替换为“”,并使用常规“Edit\Find\Replace in Path Ctrl+” Shift+R”?
或者您可以在异常的类上按 Del 并选中“安全删除(带用法搜索)”。
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)".