-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add quickfix for unreachable catch #481
Conversation
} | ||
|
||
Statement statement = ASTResolving.findParentStatement(node); | ||
if (statement != catchClause.getParent() && statement != catchClause.getBody()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you use equals(...) instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fbricon it is comparing 2 AST nodes. They should point to the same object instance in this case.
return false; | ||
} | ||
|
||
if (resultingCollections == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move that block at the beginning of the method, no need to compute anything if a simple check fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
} | ||
|
||
private static boolean isNotYetThrown(ITypeBinding binding, List<Type> thrownExceptions) { | ||
for (int i = 0; i < thrownExceptions.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use enhanced for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@Test | ||
public void testUnneededCatchBlock() throws Exception { | ||
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); | ||
StringBuffer buf = new StringBuffer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuilder
public void testUnneededCatchBlockInInitializer() throws Exception { | ||
|
||
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); | ||
StringBuffer buf = new StringBuffer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuilder
public void testUnneededCatchBlockSingle() throws Exception { | ||
|
||
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); | ||
StringBuffer buf = new StringBuffer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuilder
public void testUnneededCatchBlockWithFinally() throws Exception { | ||
|
||
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null); | ||
StringBuffer buf = new StringBuffer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuilder
test this please Hey wake up Jenkins! |
Signed-off-by: Yaohai Zheng <[email protected]>
9985ba7
to
77f9707
Compare
Thanks for the new quick fixes @yaohaizh ! |
Signed-off-by: Yaohai Zheng [email protected]
@fbricon @gorkem