mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
replace method duplicates: qualified/unqualified static access ( IDEA-23412 )
This commit is contained in:
@@ -378,6 +378,12 @@ public class DuplicatesFinder {
|
||||
final PsiExpression candidateQualifier = candidateRefExpr.getQualifierExpression();
|
||||
if (patternQualifier == null) {
|
||||
PsiClass contextClass = PsiTreeUtil.getParentOfType(pattern, PsiClass.class);
|
||||
if (candidateQualifier instanceof PsiReferenceExpression) {
|
||||
final PsiElement resolved = ((PsiReferenceExpression)candidateQualifier).resolve();
|
||||
if (resolved instanceof PsiClass && contextClass != null && contextClass.isInheritor((PsiClass)resolved, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return contextClass != null && match.registerInstanceExpression(candidateQualifier, contextClass);
|
||||
} else {
|
||||
if (candidateQualifier == null) {
|
||||
@@ -405,6 +411,14 @@ public class DuplicatesFinder {
|
||||
contextClass = thisCandidate;
|
||||
}
|
||||
return contextClass != null && match.putParameter(parameter, RefactoringUtil.createThisExpression(patternQualifier.getManager(), contextClass));
|
||||
} else if (patternQualifier instanceof PsiReferenceExpression) {
|
||||
final PsiElement resolved = ((PsiReferenceExpression)patternQualifier).resolve();
|
||||
if (resolved instanceof PsiClass) {
|
||||
final PsiClass classContext = PsiTreeUtil.getParentOfType(candidate, PsiClass.class);
|
||||
if (classContext != null && classContext.isInheritor((PsiClass)resolved, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class aa {
|
||||
public static boolean isVis<caret>ualUpdate(int update_type) {
|
||||
return update_type <= Iaaa.FULL_QUOTE_VISUAL;
|
||||
}
|
||||
}
|
||||
|
||||
interface Iaaa {
|
||||
int FULL_QUOTE_VISUAL = 0;
|
||||
}
|
||||
|
||||
class a implements Iaaa {
|
||||
int update_type = 8;
|
||||
|
||||
public static boolean blabla(int update_type) {
|
||||
return update_type <= FULL_QUOTE_VISUAL;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class aa {
|
||||
public static boolean isVisualUpdate(int update_type) {
|
||||
return update_type <= Iaaa.FULL_QUOTE_VISUAL;
|
||||
}
|
||||
}
|
||||
|
||||
interface Iaaa {
|
||||
int FULL_QUOTE_VISUAL = 0;
|
||||
}
|
||||
|
||||
class a implements Iaaa {
|
||||
int update_type = 8;
|
||||
|
||||
public static boolean blabla(int update_type) {
|
||||
return aa.isVisualUpdate(update_type);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class aa {
|
||||
public static boolean isVisualUpdate(int update_type) {
|
||||
return update_type <= Iaaa.FULL_QUOTE_VISUAL;
|
||||
}
|
||||
}
|
||||
|
||||
interface Iaaa {
|
||||
int FULL_QUOTE_VISUAL = 0;
|
||||
}
|
||||
|
||||
class a implements Iaaa {
|
||||
int update_type = 8;
|
||||
|
||||
public static boolean blab<caret>la(int update_type) {
|
||||
return update_type <= FULL_QUOTE_VISUAL;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class aa {
|
||||
public static boolean isVisualUpdate(int update_type) {
|
||||
return a.blabla(update_type);
|
||||
}
|
||||
}
|
||||
|
||||
interface Iaaa {
|
||||
int FULL_QUOTE_VISUAL = 0;
|
||||
}
|
||||
|
||||
class a implements Iaaa {
|
||||
int update_type = 8;
|
||||
|
||||
public static boolean blabla(int update_type) {
|
||||
return update_type <= FULL_QUOTE_VISUAL;
|
||||
}
|
||||
}
|
||||
@@ -65,4 +65,14 @@ public class FindMethodDuplicatesMiscTest extends FindMethodDuplicatesBaseTest {
|
||||
public void testInsertSuperQualifierWhenNameConflicts() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnqualifiedStaticAccess() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCandidateUnqualifiedStaticAccess() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user