mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
[extract duplicates] IDEA-262587: don't skip duplicates with local assignments
GitOrigin-RevId: f0385f26151e310bb070de1ad07c637b14ef3354
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a00399fe2
commit
94f3aff222
@@ -128,7 +128,6 @@ class JavaDuplicatesFinder(pattern: List<PsiElement>, private val predefinedChan
|
||||
return when {
|
||||
pattern !is PsiExpression || candidate !is PsiExpression -> false
|
||||
pattern.parent is PsiExpressionStatement -> false
|
||||
pattern is PsiReferenceExpression && pattern.parent?.parent is PsiExpressionStatement -> false
|
||||
pattern is PsiReferenceExpression && pattern.resolve() is PsiMethod && candidate is PsiReferenceExpression -> pattern.resolve() == candidate.resolve()
|
||||
else -> pattern.type.isAssignableFrom(candidate.type)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
public class Sample2 {
|
||||
|
||||
void test1(){
|
||||
<selection>int a = 1;
|
||||
int b = 2;
|
||||
a = 42;
|
||||
System.out.println(a);</selection>
|
||||
}
|
||||
|
||||
void test2(){
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
x = 42;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
public class Sample2 {
|
||||
|
||||
void test1(){
|
||||
extracted();
|
||||
}
|
||||
|
||||
private void extracted() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
a = 42;
|
||||
System.out.println(a);
|
||||
}
|
||||
|
||||
void test2(){
|
||||
extracted();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class Sample2 {
|
||||
|
||||
void test1(){
|
||||
<selection>int a = 1;
|
||||
int b = 2;
|
||||
a = 42;
|
||||
System.out.println(a);</selection>
|
||||
}
|
||||
|
||||
void test2(){
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
y = 42;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
public class Sample2 {
|
||||
|
||||
void test1(){
|
||||
extracted();
|
||||
}
|
||||
|
||||
private void extracted() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
a = 42;
|
||||
System.out.println(a);
|
||||
}
|
||||
|
||||
void test2(){
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
y = 42;
|
||||
System.out.println(x);
|
||||
}
|
||||
}
|
||||
@@ -162,6 +162,14 @@ class ExtractMethodAndDuplicatesInplaceTest: LightJavaCodeInsightTestCase() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testLocalAssignmentDuplicates(){
|
||||
doTest();
|
||||
}
|
||||
|
||||
fun testWrongLocalAssignmentDuplicates(){
|
||||
doTest();
|
||||
}
|
||||
|
||||
fun testRefactoringListener(){
|
||||
templateTest {
|
||||
configureByFile("$BASE_PATH/${getTestName(false)}.java")
|
||||
|
||||
Reference in New Issue
Block a user