mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-65252 Static nested classes are first proposal on values
This commit is contained in:
+5
@@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends CompletionWeigher {
|
||||
|
||||
enum MyResult {
|
||||
className,
|
||||
classLiteral,
|
||||
normal,
|
||||
superMethodParameters,
|
||||
@@ -54,6 +55,10 @@ public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends Completio
|
||||
if (object instanceof PsiAnnotationMethod && ((PsiAnnotationMethod)object).getContainingClass().isAnnotationType()) {
|
||||
return MyResult.annoMethod;
|
||||
}
|
||||
|
||||
if (object instanceof PsiClass) {
|
||||
return MyResult.className;
|
||||
}
|
||||
}
|
||||
|
||||
return MyResult.normal;
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
abstract class Base {
|
||||
public static @interface IfNotParsed {}
|
||||
|
||||
static class X {}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
|
||||
}
|
||||
class B {
|
||||
void foo(Derived b) {
|
||||
b.<caret>
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -8,6 +8,7 @@ import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
|
||||
import java.util.List;
|
||||
@@ -192,7 +193,12 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
incUseCount(lookup, 1);
|
||||
|
||||
assertEquals("zoo.Baaaaaaar", ((JavaPsiClassReferenceElement) lookup.getItems().get(0)).getQualifiedName());
|
||||
assertEquals("Baaaaaaar", ((JavaPsiClassReferenceElement) lookup.getItems().get(1)).getQualifiedName());
|
||||
assertEquals("Baaaaaaar", ((JavaPsiClassReferenceElement)lookup.getItems().get(1)).getQualifiedName());
|
||||
}
|
||||
|
||||
public void testDispreferInnerClasses() {
|
||||
checkPreferredItems(0); //no chosen items
|
||||
assertFalse(getLookup().getItems().get(0).getObject() instanceof PsiClass);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.lookup;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -71,7 +72,7 @@ public abstract class ComparingClassifier<T> extends Classifier<T> {
|
||||
@Override
|
||||
public void describeItems(LinkedHashMap<T, StringBuilder> map) {
|
||||
final TreeMap<Comparable, List<T>> treeMap = groupByWeights(new ArrayList<T>(map.keySet()));
|
||||
if (treeMap.size() > 1) {
|
||||
if (treeMap.size() > 1 || ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
for (Map.Entry<Comparable, List<T>> entry: treeMap.entrySet()){
|
||||
for (T t : entry.getValue()) {
|
||||
final StringBuilder builder = map.get(t);
|
||||
|
||||
Reference in New Issue
Block a user