mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
find occurrences: distinguish <> with different inference (IDEA-66176)
This commit is contained in:
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PsiDiamondTypeElementImpl;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -225,7 +226,17 @@ public class CodeInsightUtil {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}, false);
|
||||
}, new Comparator<PsiElement>() {
|
||||
@Override
|
||||
public int compare(PsiElement o1, PsiElement o2) {
|
||||
if (o1 instanceof PsiDiamondTypeElementImpl && o2 instanceof PsiDiamondTypeElementImpl) {
|
||||
final PsiDiamondType.DiamondInferenceResult thisInferenceResult = new PsiDiamondType(o1.getManager(), (PsiTypeElement)o1).resolveInferredTypes();
|
||||
final PsiDiamondType.DiamondInferenceResult otherInferenceResult = new PsiDiamondType(o2.getManager(), (PsiTypeElement)o2).resolveInferredTypes();
|
||||
return thisInferenceResult.equals(otherInferenceResult) ? 0 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
public static Editor positionCursor(final Project project, PsiFile targetFile, PsiElement element) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void foo(final ArrayList<String> anObject) {
|
||||
List<String> ls = anObject;
|
||||
List<String> lss = anObject;
|
||||
List<Integer> li = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void foo() {
|
||||
List<String> ls = <selection>new ArrayList<>()</selection>;
|
||||
List<String> lss = new ArrayList<>();
|
||||
List<Integer> li = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -264,6 +264,10 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
public void testDiamondOccurrences() throws Exception {
|
||||
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, true, false, true, false);
|
||||
}
|
||||
|
||||
private void doTestThroughHandler() throws Exception {
|
||||
configureByFile("/refactoring/introduceParameter/before" + getTestName(false) + ".java");
|
||||
new IntroduceParameterHandler().invoke(getProject(), myEditor, myFile, new DataContext() {
|
||||
|
||||
Reference in New Issue
Block a user