mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-151470 Autocomplete not suggesting after finally block
This commit is contained in:
+4
-10
@@ -99,6 +99,9 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
JavaTokenType.FLOAT_LITERAL, JavaTokenType.INTEGER_LITERAL)));
|
||||
private static final ElementPattern<PsiElement> IMPORT_REFERENCE =
|
||||
psiElement().withParent(psiElement(PsiJavaCodeReferenceElement.class).withParent(PsiImportStatementBase.class));
|
||||
private static final ElementPattern<PsiElement> CATCH_OR_FINALLY = psiElement().afterLeaf(
|
||||
psiElement().withText("}").withParent(
|
||||
psiElement(PsiCodeBlock.class).afterLeaf(PsiKeyword.TRY)));
|
||||
|
||||
@Nullable
|
||||
public static ElementFilter getReferenceFilter(PsiElement position) {
|
||||
@@ -126,7 +129,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
return ElementClassFilter.CLASS;
|
||||
}
|
||||
|
||||
if (isCatchFinallyPosition(position) ||
|
||||
if (CATCH_OR_FINALLY.accepts(position) ||
|
||||
JavaKeywordCompletion.START_SWITCH.accepts(position) ||
|
||||
JavaKeywordCompletion.isInstanceofPlace(position) ||
|
||||
JavaKeywordCompletion.isAfterPrimitiveOrArrayType(position)) {
|
||||
@@ -166,15 +169,6 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
return TrueFilter.INSTANCE;
|
||||
}
|
||||
|
||||
private static boolean isCatchFinallyPosition(PsiElement position) {
|
||||
PsiElement leaf = PsiTreeUtil.prevVisibleLeaf(position);
|
||||
return leaf != null &&
|
||||
leaf.textMatches("}") &&
|
||||
leaf.getParent() instanceof PsiCodeBlock &&
|
||||
leaf.getParent().getParent() instanceof PsiTryStatement &&
|
||||
((PsiTryStatement)leaf.getParent().getParent()).getResourceList() == null;
|
||||
}
|
||||
|
||||
private static boolean isInsideAnnotationName(PsiElement position) {
|
||||
PsiAnnotation anno = PsiTreeUtil.getParentOfType(position, PsiAnnotation.class, true, PsiMember.class);
|
||||
return anno != null && PsiTreeUtil.isAncestor(anno.getNameReferenceElement(), position, true);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
public class Test {
|
||||
void fooBarGoo() {
|
||||
try {}
|
||||
finally {}
|
||||
fbg<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class Test {
|
||||
void fooBarGoo() {
|
||||
try {}
|
||||
finally {}
|
||||
fooBarGoo();<caret>
|
||||
}
|
||||
}
|
||||
+1
@@ -479,6 +479,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
configure()
|
||||
assertStringItems 'final', 'finalize'
|
||||
}
|
||||
public void testMethodCallAfterFinally() { doTest() }
|
||||
public void testPrivateInAnonymous() throws Throwable { doTest() }
|
||||
|
||||
public void testMethodParenthesesSpaces() throws Throwable {
|
||||
|
||||
Reference in New Issue
Block a user