mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java completion: put type above signature containing that type (IDEA-181329)
This commit is contained in:
@@ -621,7 +621,11 @@ public class JavaCompletionSorting {
|
||||
@Override
|
||||
public boolean shouldLift(LookupElement shorterElement, LookupElement longerElement) {
|
||||
Object object = shorterElement.getObject();
|
||||
if (object instanceof PsiClass && longerElement.getObject() instanceof PsiClass) {
|
||||
if (!(object instanceof PsiClass)) return false;
|
||||
|
||||
if (longerElement.getUserData(JavaGenerateMemberCompletionContributor.GENERATE_ELEMENT) != null) return true;
|
||||
|
||||
if (longerElement.getObject() instanceof PsiClass) {
|
||||
PsiClass psiClass = (PsiClass)object;
|
||||
PsiFile file = psiClass.getContainingFile();
|
||||
if (file != null) {
|
||||
|
||||
+3
-1
@@ -201,7 +201,8 @@ public class JavaGenerateMemberCompletionContributor {
|
||||
}
|
||||
|
||||
PsiType type = substitutor.substitute(prototype.getReturnType());
|
||||
String signature = modifiers + (type == null ? "" : type.getPresentableText() + " ") + methodName;
|
||||
String typeAndName = (type == null ? "" : type.getPresentableText() + " ") + methodName;
|
||||
String signature = modifiers + typeAndName;
|
||||
|
||||
String parameters = "(" + StringUtil.join(prototype.getParameterList().getParameters(),
|
||||
p -> getShortParameterName(substitutor, p) + " " + p.getName(),
|
||||
@@ -209,6 +210,7 @@ public class JavaGenerateMemberCompletionContributor {
|
||||
|
||||
String overrideSignature = " @Override " + signature; // leading space to make it a middle match, under all annotation suggestions
|
||||
LookupElementBuilder element = LookupElementBuilder.create(prototype, signature).withLookupString(methodName).
|
||||
withLookupString(typeAndName).
|
||||
withLookupString(signature).withLookupString(overrideSignature).withInsertHandler(insertHandler).
|
||||
appendTailText(parameters, false).appendTailText(" {...}", true).withTypeText(typeText).withIcon(icon);
|
||||
if (prototype.isDeprecated()) {
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
private String zoo;
|
||||
public Stri<caret>
|
||||
}
|
||||
+4
@@ -824,4 +824,8 @@ class Foo {
|
||||
myFixture.assertPreferredCompletionItems 0, 'out', 'exit'
|
||||
}
|
||||
|
||||
void testPreferTypeToGeneratedMethod() {
|
||||
checkPreferredItems 0, 'String', 'public String getZoo', 'public String toString'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1662,14 +1662,14 @@ class Bar {
|
||||
|
||||
myFixture.configureByText('a.java', 'class Fooxxxxxxxxxx { Fooxxxxx<caret>a f;\n' + 'public void foo() {}\n' * 10000 + '}')
|
||||
def items = myFixture.completeBasic()
|
||||
PsiClass c1 = items[0].object
|
||||
PsiClass c1 = items[1].object
|
||||
assert !c1.physical
|
||||
assert CompletionUtil.getOriginalElement(c1)
|
||||
|
||||
getLookup().hide()
|
||||
myFixture.type('x')
|
||||
items = myFixture.completeBasic()
|
||||
PsiClass c2 = items[0].object
|
||||
PsiClass c2 = items[1].object
|
||||
assert !c2.physical
|
||||
assert CompletionUtil.getOriginalElement(c2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user