diamonds: forbid diamonds completion with anonymous rollover (IDEA-72527)

This commit is contained in:
anna
2011-08-17 18:13:49 +02:00
parent b8691cbeeb
commit b66c85fdee
5 changed files with 23 additions and 2 deletions
@@ -137,7 +137,7 @@ public class JavaInheritorsGetter extends CompletionProvider<CompletionParameter
final PsiVariable declaredVar = (PsiVariable)((PsiDeclarationStatement)statement).getDeclaredElements()[0];
final PsiNewExpression initializer = (PsiNewExpression)declaredVar.getInitializer();
final boolean hasDefaultConstructorOrNoGenericsOne = PsiDiamondType.hasDefaultConstructor(psiClass) || !PsiDiamondType.haveConstructorsGenericsParameters(psiClass);
if (hasDefaultConstructorOrNoGenericsOne && PsiDiamondType.resolveInferredTypes(initializer).getErrorMessage() == null) {
if (hasDefaultConstructorOrNoGenericsOne && PsiDiamondType.resolveInferredTypes(initializer).getErrorMessage() == null && !psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
psiType = initializer.getType();
}
}
@@ -0,0 +1,9 @@
class MyClass {
public void foo() {
MyDD<String> d = new MyDD<String>() {
}
}
}
abstract class MyDD<T> {
}
@@ -0,0 +1,8 @@
class MyClass {
public void foo() {
MyDD<String> d = new MyD<caret>
}
}
abstract class MyDD<T> {
}
@@ -41,6 +41,10 @@ public class SmartType17CompletionTest extends LightFixtureCompletionTestCase {
doTest();
}
public void testDiamondNotCollapsedInCaseOfAnonymousClasses() throws Exception {
doTest();
}
public void testDiamondPresentation() {
configureByFile("/" + getTestName(false) + ".java");
LookupElementPresentation presentation = new LookupElementPresentation();
@@ -382,7 +382,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement
myLookup.addItem(item.getLookupElement(), item.getPrefixMatcher());
myCount++;
if (myCount == 1) {
if (myCount == 1 && !ApplicationManager.getApplication().isUnitTestMode()) {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
try {