diff --git a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java index 49c967579546..cfd1594b415f 100644 --- a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java +++ b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java @@ -421,7 +421,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor { instruction = new ReturnInstruction(0, myStack, callInstruction); } else { - instruction = new GoToInstruction(0); + instruction = new GoToInstruction(0, BranchingInstruction.Role.END, PsiTreeUtil.isAncestor(exitedStatement, myCodeFragment, true)); } myCurrentFlow.addInstruction(instruction); // exited statement might be out of control flow analyzed @@ -483,7 +483,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor { instruction = new ReturnInstruction(0, myStack, callInstruction); } else { - instruction = new GoToInstruction(0); + instruction = new GoToInstruction(0, BranchingInstruction.Role.END, PsiTreeUtil.isAncestor(body, myCodeFragment, true)); } myCurrentFlow.addInstruction(instruction); addElementOffsetLater(body, false); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unwrapIfStatement/afterContinue.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unwrapIfStatement/afterContinue.java new file mode 100644 index 000000000000..252ccaa942a6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unwrapIfStatement/afterContinue.java @@ -0,0 +1,7 @@ +// "Unwrap 'if' statement" "true" +class X { + void f(){ + while (true) { + continue;//comment + } + }} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unwrapIfStatement/beforeContinue.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unwrapIfStatement/beforeContinue.java new file mode 100644 index 000000000000..c9419627253f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/unwrapIfStatement/beforeContinue.java @@ -0,0 +1,10 @@ +// "Unwrap 'if' statement" "true" +class X { + void f(){ + while (true) { + if (true) { + continue;//comment + } + System.out.println(); + } + }} \ No newline at end of file diff --git a/java/java-tests/testData/psi/controlFlow/flow10.txt b/java/java-tests/testData/psi/controlFlow/flow10.txt index daee929757ae..4e9c2a5a774d 100644 --- a/java/java-tests/testData/psi/controlFlow/flow10.txt +++ b/java/java-tests/testData/psi/controlFlow/flow10.txt @@ -7,5 +7,5 @@ 6: COND_THROW_TO 8 7: GOTO [END] 11 8: WRITE e -9: GOTO [END] 11 +9: GOTO [END] 11 RETURN 10: GOTO [END] 11 \ No newline at end of file