mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-177292 No "new" keyword completion after dot
This commit is contained in:
@@ -457,6 +457,29 @@ public class JavaKeywordCompletion {
|
||||
addKeyword(createKeyword(PsiKeyword.FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
if (isQualifiedNewContext()) {
|
||||
addKeyword(createKeyword(PsiKeyword.NEW));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isQualifiedNewContext() {
|
||||
if (myPosition.getParent() instanceof PsiReferenceExpression) {
|
||||
PsiExpression qualifier = ((PsiReferenceExpression)myPosition.getParent()).getQualifierExpression();
|
||||
PsiClass qualifierClass = PsiUtil.resolveClassInClassTypeOnly(qualifier == null ? null : qualifier.getType());
|
||||
if (qualifierClass != null &&
|
||||
ContainerUtil.exists(qualifierClass.getAllInnerClasses(), inner -> canBeCreatedInQualifiedNew(qualifierClass, inner))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canBeCreatedInQualifiedNew(PsiClass outer, PsiClass inner) {
|
||||
PsiMethod[] constructors = inner.getConstructors();
|
||||
return !inner.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
PsiUtil.isAccessible(inner, myPosition, outer) &&
|
||||
(constructors.length == 0 || ContainerUtil.exists(constructors, c -> PsiUtil.isAccessible(c, myPosition, outer)));
|
||||
}
|
||||
|
||||
private void addFileHeaderKeywords() {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
public class Test {
|
||||
public Inner getInner() {
|
||||
return this.<caret>
|
||||
}
|
||||
|
||||
public class Inner {
|
||||
public void foo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -153,6 +153,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
public void testNoStatementInForLoopCondition() { doTest(0, "synchronized", "if"); }
|
||||
public void testNoStatementInForLoopUpdate() { doTest(0, "synchronized", "if"); }
|
||||
public void testPrivateInJava9Interface() { setLanguageLevel(LanguageLevel.JDK_1_9); doTest(); }
|
||||
public void testQualifiedNew() { doTest(1, "new"); }
|
||||
|
||||
public void testOverwriteCatch() {
|
||||
configureByTestName();
|
||||
|
||||
Reference in New Issue
Block a user