stream migration: do not suggest to migrate if exceptions are thrown inside the block (IDEA-129484)

This commit is contained in:
Anna Kozlova
2014-09-12 21:36:55 +04:00
parent 3797e6027d
commit ea883dd1e7
2 changed files with 15 additions and 1 deletions
@@ -111,7 +111,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
}
});
if (effectivelyFinal[0]) {
if (effectivelyFinal[0] && ExceptionUtil.getThrownCheckedExceptions(new PsiElement[] {body}).isEmpty()) {
if (isCollectCall(body)) {
holder.registerProblem(iteratedValue, "Can be replaced with collect call",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new ReplaceWithCollectCallFix());
@@ -0,0 +1,14 @@
// "Replace with collect" "false"
import java.util.*;
public class Test {
public void foo() throws Exception {}
public static void bar(List<Test> currentImportLine) throws Exception {
for (Test test : currentImp<caret>ortLine) {
if (true) {
test.foo();
}
}
}
}