IDEA-88181 Java: complete 'return' in conditional expression

This commit is contained in:
peter
2012-07-03 12:52:32 +02:00
parent 08bd059657
commit 59466627be
4 changed files with 8 additions and 2 deletions
@@ -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) {