mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[extract method] fix: don't declare variable twice
GitOrigin-RevId: a7b8bcccb1e4bf4fb5ea35975f12767dae882813
This commit is contained in:
committed by
intellij-monorepo-bot
parent
973ce0cb93
commit
7bce69f60f
+2
-1
@@ -74,7 +74,8 @@ fun findExtractOptions(elements: List<PsiElement>): ExtractOptions {
|
||||
.map { it.copy(type = normalizeType(it.type)) }
|
||||
val parameterNames = inputParameters.map { it.name }.toSet()
|
||||
|
||||
val exposedVariables = analyzer.findExposedLocalDeclarations()
|
||||
val outputVariable = (dataOutput as? VariableOutput)?.variable
|
||||
val exposedVariables = analyzer.findExposedLocalDeclarations().filter { exposedVariable -> exposedVariable != outputVariable }
|
||||
|
||||
extractOptions = extractOptions.copy(
|
||||
dataOutput = normalizeDataOutput(dataOutput, flowOutput, elements, exposedVariables.mapNotNull { it.name }),
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class Test {
|
||||
void test(boolean condition) {
|
||||
<selection>String s = "42";</selection>
|
||||
if (condition) s = "new";
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Test {
|
||||
void test(boolean condition) {
|
||||
String s = getString();
|
||||
if (condition) s = "new";
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getString() {
|
||||
String s = "42";
|
||||
return s;
|
||||
}
|
||||
}
|
||||
+4
@@ -202,6 +202,10 @@ class ExtractMethodAndDuplicatesInplaceTest: LightJavaCodeInsightTestCase() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testChangedVariableDeclaredOnce(){
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testRefactoringListener(){
|
||||
templateTest {
|
||||
configureByFile("$BASE_PATH/${getTestName(false)}.java")
|
||||
|
||||
Reference in New Issue
Block a user