mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-88181 Java: complete 'return' in conditional expression
This commit is contained in:
@@ -628,7 +628,7 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (psiElement().withSuperParent(2, PsiConditionalExpression.class).accepts(position)) {
|
||||
if (psiElement().withSuperParent(2, PsiConditionalExpression.class).andNot(psiElement().insideStarting(psiElement(PsiConditionalExpression.class))).accepts(position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Util {
|
||||
int goo() {
|
||||
ret<caret>cond ? 1: 0;
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
public void testNewInMethodRefs() throws Exception { doTest(false); }
|
||||
public void testAbstractInInterface() throws Exception { doTest(1, "abstract"); }
|
||||
public void testCharInAnnotatedParameter() throws Exception { doTest(1, "char"); }
|
||||
public void testReturnInTernary() throws Exception { doTest(1, "return"); }
|
||||
|
||||
public void testTryInExpression() throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
|
||||
|
||||
@@ -303,7 +303,7 @@ public abstract class PsiElementPattern<T extends PsiElement,Self extends PsiEle
|
||||
});
|
||||
}
|
||||
|
||||
public Self insideStarting(final ElementPattern<PsiElement> ancestor) {
|
||||
public Self insideStarting(final ElementPattern<? extends PsiElement> ancestor) {
|
||||
return with(new PatternCondition<PsiElement>("insideStarting") {
|
||||
@Override
|
||||
public boolean accepts(@NotNull PsiElement start, ProcessingContext context) {
|
||||
|
||||
Reference in New Issue
Block a user