mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
restore that ClassInheritorsSearch returns unique results (IDEA-119628)
This commit is contained in:
+1
-1
@@ -156,7 +156,7 @@ public class ClassInheritorsSearch extends ExtensibleQueryFactory<PsiClass, Clas
|
||||
}
|
||||
|
||||
public static Query<PsiClass> search(@NotNull SearchParameters parameters) {
|
||||
return INSTANCE.createQuery(parameters);
|
||||
return INSTANCE.createUniqueResultsQuery(parameters);
|
||||
}
|
||||
|
||||
public static Query<PsiClass> search(@NotNull final PsiClass aClass, @NotNull SearchScope scope, final boolean checkDeep, final boolean checkInheritance) {
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
interface I {}
|
||||
class A implements I {}
|
||||
class B extends A implements I{}
|
||||
+1
-1
@@ -116,7 +116,7 @@ public class ImplementationsViewTest extends LightCodeInsightFixtureTestCase {
|
||||
try {
|
||||
final String[] visibleFiles = component.getVisibleFiles();
|
||||
Assert.assertArrayEquals(Arrays.toString(visibleFiles),
|
||||
new String[]{"a.java (AFoo)", "a.java (AFoo1 in AFoo)", "a.java (AFoo3 in AFoo)", "a.java (AFoo2 in AFoo)"}, visibleFiles);
|
||||
new String[]{"a.java (AFoo)", "a.java (AFoo1 in AFoo)", "a.java (AFoo2 in AFoo)", "a.java (AFoo3 in AFoo)"}, visibleFiles);
|
||||
}
|
||||
finally {
|
||||
component.removeNotify();
|
||||
|
||||
@@ -53,6 +53,10 @@ public class InheritorsTest extends PsiTestCase{
|
||||
doTest("x.Test", "", true, "x.Goo", "x.Zoo");
|
||||
}
|
||||
|
||||
public void testMultipleInheritance() throws Exception {
|
||||
doTest("I", "", true, "A", "B");
|
||||
}
|
||||
|
||||
private void doTest(String className, String packageScopeName, final boolean deep, String... inheritorNames) throws Exception {
|
||||
final PsiClass aClass = myJavaFacade.findClass(className);
|
||||
assertNotNull(aClass);
|
||||
|
||||
+15
-8
@@ -60,10 +60,8 @@ import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ImplementationViewComponent extends JPanel {
|
||||
@NonNls private static final String TEXT_PAGE_KEY = "Text";
|
||||
@@ -173,7 +171,7 @@ public class ImplementationViewComponent extends JPanel {
|
||||
toolbarPanel.add(myToolbar.getComponent(), gc);
|
||||
|
||||
setPreferredSize(new Dimension(600, 400));
|
||||
|
||||
|
||||
update(elements, new PairFunction<PsiElement[], List<FileDescriptor>, Boolean>() {
|
||||
@Override
|
||||
public Boolean fun(final PsiElement[] psiElements, final List<FileDescriptor> fileDescriptors) {
|
||||
@@ -273,7 +271,7 @@ public class ImplementationViewComponent extends JPanel {
|
||||
@Override
|
||||
public Boolean fun(PsiElement[] psiElements, List<FileDescriptor> fileDescriptors) {
|
||||
if (psiElements.length == 0) return false;
|
||||
|
||||
|
||||
final Project project = psiElements[0].getProject();
|
||||
myElements = psiElements;
|
||||
|
||||
@@ -302,7 +300,7 @@ public class ImplementationViewComponent extends JPanel {
|
||||
else {
|
||||
myFileChooser.setVisible(false);
|
||||
myCountLabel.setVisible(false);
|
||||
|
||||
|
||||
VirtualFile file = psiFile.getVirtualFile();
|
||||
if (file != null) {
|
||||
myLabel.setIcon(getIconForFile(psiFile));
|
||||
@@ -321,9 +319,9 @@ public class ImplementationViewComponent extends JPanel {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void update(@NotNull PsiElement[] elements, @NotNull PairFunction<PsiElement[], List<FileDescriptor>, Boolean> fun) {
|
||||
List<PsiElement> candidates = new ArrayList<PsiElement>(elements.length);
|
||||
List<FileDescriptor> files = new ArrayList<FileDescriptor>(elements.length);
|
||||
@@ -333,6 +331,15 @@ public class ImplementationViewComponent extends JPanel {
|
||||
names.add(((PsiNamedElement)element).getName());
|
||||
}
|
||||
}
|
||||
Arrays.sort(elements, new Comparator<PsiElement>() {
|
||||
@Override
|
||||
public int compare(PsiElement e1, PsiElement e2) {
|
||||
if (e1 instanceof PsiNamedElement && e2 instanceof PsiNamedElement) {
|
||||
return Comparing.compare(((PsiNamedElement)e1).getName(), ((PsiNamedElement)e2).getName());
|
||||
}
|
||||
return e1.hashCode() - e2.hashCode();
|
||||
}
|
||||
});
|
||||
for (PsiElement element : elements) {
|
||||
PsiFile file = getContainingFile(element);
|
||||
if (file == null) continue;
|
||||
|
||||
Reference in New Issue
Block a user