mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java completion: don't suggest class keywords in array variable initializer (IDEA-CR-23174)
This commit is contained in:
@@ -516,12 +516,12 @@ public class JavaKeywordCompletion {
|
||||
addKeyword(new OverridableSpace(createKeyword(s), TailType.HUMBLE_SPACE_BEFORE_WORD));
|
||||
}
|
||||
|
||||
boolean inExpression = PsiTreeUtil.getParentOfType(myPosition, PsiExpression.class, true, PsiMember.class) != null;
|
||||
boolean inCodeBlock = PsiTreeUtil.getParentOfType(myPosition, PsiCodeBlock.class, true, PsiMember.class) != null;
|
||||
if (inCodeBlock || !inExpression) {
|
||||
PsiExpression expression = PsiTreeUtil.getParentOfType(myPosition, PsiExpression.class, true, PsiMember.class);
|
||||
if (expression != null && expression.getParent() instanceof PsiExpressionStatement) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.CLASS), TailType.HUMBLE_SPACE_BEFORE_WORD));
|
||||
}
|
||||
if (!inExpression) {
|
||||
if (expression == null && PsiTreeUtil.getParentOfType(myPosition, PsiCodeBlock.class, true, PsiMember.class) == null) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.CLASS), TailType.HUMBLE_SPACE_BEFORE_WORD));
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.INTERFACE), TailType.HUMBLE_SPACE_BEFORE_WORD));
|
||||
if (PsiUtil.isLanguageLevel5OrHigher(myPosition)) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.ENUM), TailType.INSERT_SPACE));
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class MyTest {
|
||||
void foo() {
|
||||
String[] a = new String[]{
|
||||
<caret> "a",
|
||||
"b"};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -125,7 +125,8 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
public void testPrimitivesInClassAnnotationAttribute() { doTest(3, "true", "int", "boolean"); }
|
||||
public void testPrimitivesInMethodReturningArray() { doTest(2, "true", "byte", "boolean"); }
|
||||
|
||||
public void testNoClassKeywordsInArrayInitializer() { doTest(0, "class", "interface", "enum"); }
|
||||
public void testNoClassKeywordsInLocalArrayInitializer() { doTest(0, "class", "interface", "enum"); }
|
||||
public void testNoClassKeywordsInFieldArrayInitializer() { doTest(0, "class", "interface", "enum"); }
|
||||
|
||||
public void testImportStatic() { doTest(1, "static"); }
|
||||
public void testAbstractInInterface() { doTest(1, "abstract"); }
|
||||
|
||||
Reference in New Issue
Block a user