disable completion after enum constant (IDEA-199935)

This commit is contained in:
peter
2018-10-05 18:22:23 +02:00
parent 4a5c0d1035
commit 03fd1b00f5
3 changed files with 15 additions and 2 deletions
@@ -98,6 +98,8 @@ public class JavaCompletionContributor extends CompletionContributor {
psiElement().withText("}").withParent(
psiElement(PsiCodeBlock.class).afterLeaf(PsiKeyword.TRY)));
private static final ElementPattern<PsiElement> INSIDE_CONSTRUCTOR = psiElement().inside(psiMethod().constructor(true));
private static final ElementPattern<PsiElement> AFTER_ENUM_CONSTANT =
psiElement().inside(PsiTypeElement.class).afterLeaf(psiElement().inside(true, psiElement(PsiEnumConstant.class), psiClass()));
@Nullable
public static ElementFilter getReferenceFilter(PsiElement position) {
@@ -219,7 +221,9 @@ public class JavaCompletionContributor extends CompletionContributor {
return;
}
if (AFTER_NUMBER_LITERAL.accepts(position) || UNEXPECTED_REFERENCE_AFTER_DOT.accepts(position)) {
if (AFTER_NUMBER_LITERAL.accepts(position) ||
UNEXPECTED_REFERENCE_AFTER_DOT.accepts(position) ||
AFTER_ENUM_CONSTANT.accepts(position)) {
_result.stopHere();
return;
}
@@ -512,7 +516,9 @@ public class JavaCompletionContributor extends CompletionContributor {
boolean isSecondCompletion = parameters.getInvocationCount() >= 2;
PsiElement position = parameters.getPosition();
if (JavaKeywordCompletion.isInstanceofPlace(position) || JavaMemberNameCompletionContributor.INSIDE_TYPE_PARAMS_PATTERN.accepts(position)) {
if (JavaKeywordCompletion.isInstanceofPlace(position) ||
JavaMemberNameCompletionContributor.INSIDE_TYPE_PARAMS_PATTERN.accepts(position) ||
AFTER_ENUM_CONSTANT.accepts(position)) {
return false;
}
@@ -0,0 +1,5 @@
enum MarkerType {
QUERY, SYNONYM, CLASS_ALIAS, NAMED_QUERY
s<caret>
}
@@ -1869,4 +1869,6 @@ class Abc {
myFixture.checkResult 'class Foo<T> { Foo<List<String>><caret> }'
}
void testNoSuggestionsAfterEnumConstant() { doAntiTest() }
}