[extract method] IDEA-278872: fix missed return variable

GitOrigin-RevId: 55ffed6010a531c34dfa18e22ad5b82ced9599ba
This commit is contained in:
Alexandr Suhinin
2021-10-14 09:49:26 +00:00
committed by intellij-monorepo-bot
parent f40371f009
commit c3afc8b902
4 changed files with 33 additions and 3 deletions
@@ -83,9 +83,7 @@ class CodeFragmentAnalyzer(val elements: List<PsiElement>) {
}
fun findOutputVariables(): List<PsiVariable> {
val exitPoints = IntArrayList()
ControlFlowUtil.findExitPointsAndStatements(flow, flowRange.first, flowRange.last, exitPoints, *DEFAULT_EXIT_STATEMENTS_CLASSES)
return ControlFlowUtil.getOutputVariables(flow, flowRange.first, flowRange.last, exitPoints.toIntArray()).distinct()
return ControlFlowUtil.getOutputVariables(flow, flowRange.first, flowRange.last, findExitPoints().toIntArray()).distinct()
}
fun findUndeclaredVariables(): List<PsiVariable> {
@@ -0,0 +1,10 @@
class Test {
void test() {
<selection>final String str = "atata";
do {
System.out.println();
} while (Math.random() > 0.5);</selection>
System.out.println(str);
}
}
@@ -0,0 +1,18 @@
import org.jetbrains.annotations.NotNull;
class Test {
void test() {
final String str = getString();
System.out.println(str);
}
@NotNull
private String getString() {
final String str = "atata";
do {
System.out.println();
} while (Math.random() > 0.5);
return str;
}
}
@@ -158,6 +158,10 @@ class ExtractMethodAndDuplicatesInplaceTest: LightJavaCodeInsightTestCase() {
doTest()
}
fun testIDEA278872(){
doTest()
}
fun testRefactoringListener(){
templateTest {
configureByFile("$BASE_PATH/${getTestName(false)}.java")