mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
expected type should always be at the top of the lookup in smart completion after new
This commit is contained in:
@@ -55,7 +55,9 @@ public class JavaCompletionSorting {
|
||||
final boolean afterNew = JavaSmartCompletionContributor.AFTER_NEW.accepts(position);
|
||||
|
||||
List<LookupElementWeigher> afterNegativeStats = new ArrayList<LookupElementWeigher>();
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, smart ? new PreferDefaultTypeWeigher(expectedTypes, parameters) : preferStatics(position));
|
||||
if (!smart) {
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, preferStatics(position));
|
||||
}
|
||||
afterNegativeStats.add(new PreferLocalVariablesLiteralsAndAnnoMethodsWeigher(type, position));
|
||||
ContainerUtil.addIfNotNull(afterNegativeStats, recursion(parameters, expectedTypes));
|
||||
if (!smart && !afterNew) {
|
||||
@@ -74,6 +76,9 @@ public class JavaCompletionSorting {
|
||||
if (!smart && afterNew) {
|
||||
sorter = sorter.weighBefore("liftShorter", new PreferExpected(true, expectedTypes));
|
||||
}
|
||||
if (smart) {
|
||||
sorter = sorter.weighBefore("negativeStats", new PreferDefaultTypeWeigher(expectedTypes, parameters));
|
||||
}
|
||||
sorter = sorter.weighAfter("negativeStats", afterNegativeStats.toArray(new LookupElementWeigher[afterNegativeStats.size()]));
|
||||
sorter = sorter.weighAfter("prefix", new PreferNonGeneric(), new PreferAccessible(position), new PreferSimple(), new PreferEnumConstants(parameters));
|
||||
sorter = sorter.weighAfter("proximity", afterProximity.toArray(new LookupElementWeigher[afterProximity.size()]));
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.*;
|
||||
|
||||
public class FooBean3 extends JComponent {
|
||||
|
||||
{
|
||||
List<String> l = new <caret>
|
||||
}
|
||||
}
|
||||
+12
-2
@@ -40,14 +40,24 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
imitateItemSelection(lookup, 2); //Container
|
||||
}
|
||||
refreshSorting(lookup);
|
||||
assertPreferredItems(0, "Container", "FooBean3", "JComponent");
|
||||
assertPreferredItems(2, "Component", "String", "Container", "FooBean3", "JComponent");
|
||||
|
||||
int component = lookup.items.findIndexOf { it.lookupString == 'Component' }
|
||||
for (int i = 0; i < StatisticsManager.OBLIVION_THRESHOLD; i++) {
|
||||
imitateItemSelection(lookup, component);
|
||||
}
|
||||
refreshSorting(lookup);
|
||||
assertPreferredItems(0, "Component", "Container");
|
||||
assertPreferredItems(1, "String", "Component", "FooBean3");
|
||||
}
|
||||
|
||||
public void testNewListAlwaysFirst() {
|
||||
def lookup = invokeCompletion(getTestName(false) + ".java")
|
||||
assertPreferredItems 1, 'List', 'AbstractList', 'AbstractSequentialList', 'ArrayList'
|
||||
for (int i = 0; i < StatisticsManager.OBLIVION_THRESHOLD + 10; i++) {
|
||||
imitateItemSelection(lookup, 3) //ArrayList
|
||||
}
|
||||
refreshSorting(lookup)
|
||||
assertPreferredItems 1, 'List', 'ArrayList', 'AbstractList', 'AbstractSequentialList'
|
||||
}
|
||||
|
||||
public void testNoStatsOnUnsuccessfulAttempt() {
|
||||
|
||||
Reference in New Issue
Block a user