mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prefer lookup items with shorter tail text (e.g. List#add(element) without index)
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
public class Usage {
|
||||
void foo(java.util.List<String> l){
|
||||
l.ad<caret>
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class ParameterInfoTest extends LightCodeInsightFixtureTestCase {
|
||||
"void bar2(int a);" +
|
||||
"}");
|
||||
LookupElement[] elements = myFixture.completeBasic();
|
||||
assertEquals("(int a)", LookupElementPresentation.renderElement(elements[1]).getTailText());
|
||||
assertEquals("(String a)", LookupElementPresentation.renderElement(elements[1]).getTailText());
|
||||
myFixture.getLookup().setCurrentItem(elements[1]);
|
||||
myFixture.type('\n');
|
||||
|
||||
@@ -234,7 +234,7 @@ public class ParameterInfoTest extends LightCodeInsightFixtureTestCase {
|
||||
assertEquals("<html>String a</html>", parameterPresentation(1, -1));
|
||||
assertEquals("<html>int a</html>", parameterPresentation(2, -1));
|
||||
|
||||
checkHighlighted(2);
|
||||
checkHighlighted(1);
|
||||
}
|
||||
|
||||
public void testHighlightConstructorJustChosenInCompletion() {
|
||||
@@ -249,7 +249,7 @@ public class ParameterInfoTest extends LightCodeInsightFixtureTestCase {
|
||||
"class Bar2 {}");
|
||||
myFixture.configureByText("a.java", "class Foo {{ new Bar<caret> }}");
|
||||
LookupElement[] elements = myFixture.completeBasic();
|
||||
assertEquals("(String a) (default package)", LookupElementPresentation.renderElement(elements[2]).getTailText());
|
||||
assertEquals("(boolean a) (default package)", LookupElementPresentation.renderElement(elements[2]).getTailText());
|
||||
myFixture.getLookup().setCurrentItem(elements[2]);
|
||||
myFixture.type('\n');
|
||||
myFixture.checkResult("class Foo {{ new Bar(<caret>) }}");
|
||||
@@ -258,7 +258,7 @@ public class ParameterInfoTest extends LightCodeInsightFixtureTestCase {
|
||||
assertEquals("<html>String a</html>", parameterPresentation(1, -1));
|
||||
assertEquals("<html>int a</html>", parameterPresentation(2, -1));
|
||||
|
||||
checkHighlighted(1);
|
||||
checkHighlighted(0);
|
||||
}
|
||||
|
||||
private void checkHighlighted(int lineIndex) {
|
||||
|
||||
+6
@@ -767,4 +767,10 @@ class ContainerUtil extends ContainerUtilRt {
|
||||
assertPreferredItems 0, 'ContainerUtil', 'ConflictsUtil'
|
||||
}
|
||||
|
||||
void testPreferListAddWithoutIndex() {
|
||||
checkPreferredItems 0, 'add', 'add', 'addAll', 'addAll'
|
||||
assert LookupElementPresentation.renderElement(myFixture.lookupElements[1]).tailText.contains('int index')
|
||||
assert LookupElementPresentation.renderElement(myFixture.lookupElements[3]).tailText.contains('int index')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -144,12 +144,12 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
void testMethodItemPresentationGenerics() {
|
||||
configure()
|
||||
LookupElementPresentation presentation = renderElement(myItems[0])
|
||||
LookupElementPresentation presentation = renderElement(myItems[1])
|
||||
assert "add" == presentation.itemText
|
||||
assert "(int index, String element)" == presentation.tailText
|
||||
assert "void" == presentation.typeText
|
||||
|
||||
presentation = renderElement(myItems[1])
|
||||
presentation = renderElement(myItems[0])
|
||||
assert "(String o)" == presentation.tailText
|
||||
assert "boolean" == presentation.typeText
|
||||
|
||||
|
||||
+2
-1
@@ -161,7 +161,8 @@ public class CompletionLookupArranger extends LookupArranger {
|
||||
public void addElement(LookupElement element, LookupElementPresentation presentation) {
|
||||
StatisticsWeigher.clearBaseStatisticsInfo(element);
|
||||
|
||||
final String invariant = presentation.getItemText() + "\0###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText();
|
||||
String tail = getTailTextOrSpace(presentation);
|
||||
String invariant = presentation.getItemText() + "\0###" + String.format("%02d", tail.length()) + tail + "###" + presentation.getTypeText();
|
||||
element.putUserData(PRESENTATION_INVARIANT, invariant);
|
||||
element.putUserData(GLOBAL_PRESENTATION_INVARIANT, invariant);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user