java completion: make recursion weigher less important than by-kind, because now it can lead to very unexpected sorting

This commit is contained in:
peter
2014-02-04 15:27:15 +01:00
parent 528f460761
commit 9c67ca6170
4 changed files with 7 additions and 19 deletions
@@ -75,11 +75,12 @@ public class JavaCompletionSorting {
if (!smart) {
ContainerUtil.addIfNotNull(afterPrefix, preferStatics(position, expectedTypes));
}
ContainerUtil.addIfNotNull(afterPrefix, recursion(parameters, expectedTypes));
if (!smart && !afterNew) {
afterPrefix.add(new PreferExpected(false, expectedTypes));
}
Collections.addAll(afterPrefix, new PreferByKindWeigher(type, position), new PreferSimilarlyEnding(expectedTypes),
afterPrefix.add(new PreferByKindWeigher(type, position));
ContainerUtil.addIfNotNull(afterPrefix, recursion(parameters, expectedTypes));
Collections.addAll(afterPrefix, new PreferSimilarlyEnding(expectedTypes),
new PreferNonGeneric(), new PreferAccessible(position), new PreferSimple());
sorter = sorter.weighAfter("prefix", afterPrefix.toArray(new LookupElementWeigher[afterPrefix.size()]));
@@ -1,9 +0,0 @@
public class Aaaaaaa {
private final String aaa;
Aaaaaaa(Object aabbb) {
aaa = "";
aaa = true ? null : aa<caret>
}
}
@@ -117,10 +117,6 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
checkPreferredItems(0, "aabbb", "aaa");
}
public void testDispreferDeclaredOfExpectedType() throws Throwable {
checkPreferredItems(0, "aabbb", "aaa");
}
public void testDispreferImpls() throws Throwable {
myFixture.addClass("package foo; public class Xxx {}");
configureSecondCompletion();
@@ -456,7 +452,7 @@ interface TxANotAnno {}
myFixture.addClass('public class fooAClass {}')
configureNoCompletion(getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
assertPreferredItems(0, 'fooy', 'fooAClass', 'fooBar', 'foox');
assertPreferredItems(0, 'fooy', 'foox', 'fooAClass', 'fooBar');
}
public void testChangePreselectionOnSecondInvocation() {
@@ -161,7 +161,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testPreferParametersToGetters() throws Throwable {
checkPreferredItems(0, "a", "I._1", "valueOf", "getLastI");
checkPreferredItems(0, "a", "I._1", "getLastI", "valueOf");
}
public void testExpectedInterfaceShouldGoFirst() throws Throwable {
@@ -178,7 +178,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testPreferNonRecursiveMethodParams() throws Throwable {
checkPreferredItems(0, "b", "hashCode", "s", "a");
checkPreferredItems(0, "b", "s", "a", "hashCode");
}
public void testPreferDelegatingMethodParams() throws Throwable {
@@ -302,7 +302,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testDispreferGetterInSetterCall() {
checkPreferredItems 0, 'getZooColor', 'hashCode', 'color', 'getColor'
checkPreferredItems 0, 'color', 'getZooColor', 'getColor', 'hashCode'
}
public void testPreferOtherGetterInSetterCall() {
checkPreferredItems 0, 'color', 'getColor', 'getZooColor', 'hashCode'