mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prefer the expected type even if it's inner
This commit is contained in:
+5
-5
@@ -20,7 +20,6 @@ import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -34,11 +33,12 @@ public class PreferExpectedTypeWeigher extends CompletionWeigher {
|
||||
}
|
||||
|
||||
public MyResult weigh(@NotNull final LookupElement item, @NotNull final CompletionLocation location) {
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
if (location.getCompletionType() != CompletionType.BASIC) return MyResult.normal;
|
||||
if (item.getObject() instanceof PsiClass) return MyResult.normal;
|
||||
if (item.getObject() instanceof PsiClass) {
|
||||
if (!JavaSmartCompletionContributor.AFTER_NEW.accepts(location.getCompletionParameters().getPosition())) {
|
||||
return MyResult.normal;
|
||||
}
|
||||
}
|
||||
|
||||
ExpectedTypeInfo[] expectedInfos = JavaCompletionUtil.EXPECTED_TYPES.getValue(location);
|
||||
if (expectedInfos == null) return MyResult.normal;
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foooo {
|
||||
interface Bar {}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
{
|
||||
Foooo.Bar c = new Fooo<caret>x
|
||||
}
|
||||
}
|
||||
+8
@@ -152,4 +152,12 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems(0, "final", "finalize");
|
||||
}
|
||||
|
||||
public void testPreferNewExpectedInner() throws Throwable {
|
||||
checkPreferredItems(0, "Foooo.Bar", "Foooo");
|
||||
|
||||
/*final LookupElementPresentation presentation = new LookupElementPresentation();
|
||||
getLookup().getItems().get(0).renderElement(presentation);
|
||||
assertEquals("Foooo.Bar", presentation.getItemText());*/
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user