IDEA-221379 Unexpected "instanceof" keyword completion in annotation

GitOrigin-RevId: 8058445f8b789fecf63058a05b5db1aa0ce39eb1
This commit is contained in:
peter
2019-09-30 10:32:59 +00:00
committed by intellij-monorepo-bot
parent 91c04c991f
commit fc82e319c3
3 changed files with 6 additions and 1 deletions
@@ -611,7 +611,8 @@ public class JavaKeywordCompletion {
if (prev == null) return false;
PsiElement expr = PsiTreeUtil.getParentOfType(prev, PsiExpression.class);
if (expr != null && expr.getTextRange().getEndOffset() == prev.getTextRange().getEndOffset()) {
if (expr != null && expr.getTextRange().getEndOffset() == prev.getTextRange().getEndOffset() &&
PsiTreeUtil.getParentOfType(expr, PsiAnnotation.class) == null) {
return true;
}
@@ -0,0 +1,3 @@
class Foo {
@Language("RegExp" <caret>x) String pattern;
}
@@ -116,6 +116,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
public void testSpaceAfterInstanceof() { doTest(); }
public void testInstanceofAfterUnresolved() { doTest(1, "instanceof"); }
public void testInstanceofAfterStatementStart() { doTest(1, "instanceof"); }
public void testNoInstanceofInAnnotation() { doTest(0, "instanceof"); }
public void testInstanceofNegation() {
configureByTestName();