mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-89114 Unsuitable completion proposals in annotation attribute value
This commit is contained in:
@@ -135,6 +135,7 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
and(JavaSmartCompletionContributor.INSIDE_EXPRESSION,
|
||||
not(psiElement().afterLeaf(PsiKeyword.CASE)),
|
||||
not(psiElement().afterLeaf(psiElement().withText(".").afterLeaf(PsiKeyword.THIS, PsiKeyword.SUPER))),
|
||||
not(psiElement().inside(PsiAnnotation.class)),
|
||||
not(START_SWITCH));
|
||||
|
||||
public static final AndFilter CLASS_START = new AndFilter(
|
||||
@@ -142,7 +143,8 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
END_OF_BLOCK,
|
||||
new PatternFilter(psiElement().afterLeaf(
|
||||
or(
|
||||
psiElement().withoutText(".").inside(psiElement(PsiModifierList.class).withParent(not(psiElement(PsiParameter.class)))),
|
||||
psiElement().withoutText(".").inside(psiElement(PsiModifierList.class).withParent(not(psiElement(PsiParameter.class)))).andNot(
|
||||
psiElement().inside(PsiAnnotationParameterList.class)),
|
||||
psiElement().isNull())))
|
||||
),
|
||||
new PatternFilter(not(psiElement().afterLeaf("@"))));
|
||||
@@ -486,8 +488,10 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
}
|
||||
|
||||
if (EXPR_KEYWORDS.accepts(position)) {
|
||||
result.addElement(TailTypeDecorator.withTail(createKeyword(position, PsiKeyword.NEW), TailType.INSERT_SPACE));
|
||||
result.addElement(createKeyword(position, PsiKeyword.NULL));
|
||||
if (PsiTreeUtil.getParentOfType(position, PsiAnnotation.class) == null) {
|
||||
result.addElement(TailTypeDecorator.withTail(createKeyword(position, PsiKeyword.NEW), TailType.INSERT_SPACE));
|
||||
result.addElement(createKeyword(position, PsiKeyword.NULL));
|
||||
}
|
||||
result.addElement(createKeyword(position, PsiKeyword.TRUE));
|
||||
result.addElement(createKeyword(position, PsiKeyword.FALSE));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
public class Util {
|
||||
@Foo(val=<caret>) void foo(String[] args) { }
|
||||
}
|
||||
+14
@@ -270,6 +270,20 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
assert "B" in myFixture.lookupElementStrings
|
||||
}
|
||||
|
||||
public void testAnnoParameterValue() throws Exception {
|
||||
configure()
|
||||
def strings = myFixture.lookupElementStrings
|
||||
assert 'AssertionError' in strings
|
||||
assert !('enum' in strings)
|
||||
assert !('final' in strings)
|
||||
assert !('equals' in strings)
|
||||
assert !('new' in strings)
|
||||
assert !('null' in strings)
|
||||
assert !('public' in strings)
|
||||
assert !('super' in strings)
|
||||
assert !('null' in strings)
|
||||
}
|
||||
|
||||
public void testAfterInstanceof() throws Exception {
|
||||
configureByFile("AfterInstanceof.java");
|
||||
assert "A" in myFixture.lookupElementStrings
|
||||
|
||||
Reference in New Issue
Block a user