mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract method: don't include predefined 0 into exit points when try/finally is processed (IDEA-146332)
This commit is contained in:
@@ -326,7 +326,7 @@ public class ControlFlowUtil {
|
||||
// process chain of goto's
|
||||
gotoOffset = promoteThroughGotoChain(flow, gotoOffset);
|
||||
|
||||
if (!exitPoints.contains(gotoOffset) && (gotoOffset >= end || gotoOffset < start)) {
|
||||
if (!exitPoints.contains(gotoOffset) && (gotoOffset >= end || gotoOffset < start) && gotoOffset > 0) {
|
||||
exitPoints.add(gotoOffset);
|
||||
}
|
||||
if (gotoOffset >= end || gotoOffset < start) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
private void foo() {
|
||||
System.out.println();
|
||||
<selection>try {}
|
||||
finally {
|
||||
while (true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
</selection>
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
private void foo() {
|
||||
System.out.println();
|
||||
newMethod();
|
||||
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
try {}
|
||||
finally {
|
||||
while (true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
@@ -36,7 +35,6 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
@@ -769,6 +767,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSingleExitPOintWithTryFinally() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTestDisabledParam() throws PrepareFailedException {
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
settings.ELSE_ON_NEW_LINE = true;
|
||||
|
||||
Reference in New Issue
Block a user