mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use the deepest super method for completion statistics
This commit is contained in:
+6
-1
@@ -29,7 +29,7 @@ public class JavaCompletionStatistician extends CompletionStatistician{
|
||||
|
||||
@Override
|
||||
public StatisticsInfo serialize(final LookupElement element, final CompletionLocation location) {
|
||||
final Object o = element.getObject();
|
||||
Object o = element.getObject();
|
||||
|
||||
if (o instanceof PsiLocalVariable || o instanceof PsiParameter || o instanceof PsiThisExpression) {
|
||||
return StatisticsInfo.EMPTY;
|
||||
@@ -47,6 +47,11 @@ public class JavaCompletionStatistician extends CompletionStatistician{
|
||||
PsiType expectedType = infos != null && infos.length > 0 ? infos[0].getDefaultType() : null;
|
||||
return new StatisticsInfo(JavaStatisticsManager.getAfterNewKey(expectedType), key2);
|
||||
}
|
||||
|
||||
if (o instanceof PsiMethod) {
|
||||
o = RecursionWeigher.findDeepestSuper((PsiMethod)o);
|
||||
}
|
||||
|
||||
PsiClass containingClass = ((PsiMember)o).getContainingClass();
|
||||
if (containingClass != null) {
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
|
||||
|
||||
@@ -197,7 +197,7 @@ class RecursionWeigher extends LookupElementWeigher {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static PsiMethod findDeepestSuper(@NotNull final PsiMethod method) {
|
||||
public static PsiMethod findDeepestSuper(@NotNull final PsiMethod method) {
|
||||
final PsiMethod first = DeepestSuperMethodsSearch.search(method).findFirst();
|
||||
return first == null ? method : first;
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class AbstractSet {
|
||||
public void addX() {}
|
||||
public void addY() {}
|
||||
}
|
||||
|
||||
class MySet1 extends AbstractSet {
|
||||
public void addX() {}
|
||||
}
|
||||
class MySet2 extends AbstractSet {
|
||||
public void addX() {}
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
void foo(MySet1 set1, MySet2 set2) {
|
||||
set1.ad<caret>
|
||||
}
|
||||
}
|
||||
+13
@@ -510,6 +510,19 @@ import java.lang.annotation.Target;
|
||||
assertPreferredItems 0, 'contains', 'containsAll'
|
||||
}
|
||||
|
||||
public void testDeepestSuperMethodStats() {
|
||||
invokeCompletion(getTestName(false) + ".java")
|
||||
assertPreferredItems 0, 'addX', 'addY'
|
||||
myFixture.type('y\n;set1.ad')
|
||||
|
||||
myFixture.completeBasic()
|
||||
assertPreferredItems 0, 'addY', 'addX'
|
||||
myFixture.type('x\n;set2.ad')
|
||||
|
||||
myFixture.completeBasic()
|
||||
assertPreferredItems 0, 'addX', 'addY'
|
||||
}
|
||||
|
||||
public void testCommonPrefixMoreImportantThanKind() {
|
||||
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE;
|
||||
checkPreferredItems(0, 'PsiElement', 'psiElement')
|
||||
|
||||
Reference in New Issue
Block a user