getting rid of PrecededByFilter

This commit is contained in:
Dmitry Jemerov
2011-09-12 15:20:04 +02:00
parent 7d2f1e57ee
commit d46f02b98a
8 changed files with 40 additions and 5 deletions

View File

@@ -327,8 +327,8 @@ public class PyKeywordCompletionContributor extends PySeeingOriginalCompletionCo
private static final FilterPattern IN_DEFINITION = new FilterPattern(new InDefinitionFilter());
private static final FilterPattern AFTER_IF = new FilterPattern(new PrecededByFilter(psiElement(PyIfStatement.class)));
private static final FilterPattern AFTER_TRY = new FilterPattern(new PrecededByFilter(psiElement(PyTryExceptStatement.class)));
private static final PsiElementPattern.Capture<PsiElement> AFTER_IF = afterStatement(psiElement(PyIfStatement.class));
private static final PsiElementPattern.Capture<PsiElement> AFTER_TRY = afterStatement(psiElement(PyTryExceptStatement.class));
private static final FilterPattern AFTER_LOOP_NO_ELSE = new FilterPattern(new PrecededByFilter(
psiElement()
@@ -336,9 +336,14 @@ public class PyKeywordCompletionContributor extends PySeeingOriginalCompletionCo
.withLastChild(StandardPatterns.not(psiElement(PyElsePart.class)))
));
private static final FilterPattern AFTER_COND_STMT_NO_ELSE = new FilterPattern(new PrecededByFilter(
psiElement().withChild(psiElement(PyConditionalStatementPart.class)).withLastChild(StandardPatterns.not(psiElement(PyElsePart.class)))
));
private static final PsiElementPattern.Capture<PsiElement> AFTER_COND_STMT_NO_ELSE =
afterStatement(psiElement().withChild(psiElement(PyConditionalStatementPart.class))
.withLastChild(StandardPatterns.not(psiElement(PyElsePart.class))));
private static <T extends PsiElement> PsiElementPattern.Capture<PsiElement> afterStatement(final PsiElementPattern.Capture<T> statementPattern) {
return psiElement().atStartOf(psiElement(PyExpressionStatement.class)
.afterSiblingSkipping(psiElement().whitespaceCommentEmptyOrError(), statementPattern));
}
private static final FilterPattern AFTER_TRY_NO_ELSE = new FilterPattern(new PrecededByFilter(
psiElement().withChild(psiElement(PyTryPart.class)).withLastChild(StandardPatterns.not(psiElement(PyElsePart.class)))

View File

@@ -0,0 +1,3 @@
if True:
a = 1
elif <caret>:

View File

@@ -0,0 +1,3 @@
if True:
a = 1
eli<caret>

View File

@@ -0,0 +1,3 @@
if True:
a = 1
else:

View File

@@ -0,0 +1,3 @@
if True:
a = 1
els<caret>

View File

@@ -0,0 +1,3 @@
try:
a = 1
except <caret>:

View File

@@ -0,0 +1,3 @@
try:
a = 1
exce<caret>

View File

@@ -265,15 +265,27 @@ public class PythonCompletionTest extends PyLightFixtureTestCase {
public void testElse() {
doTest();
}
public void testElseNotIndented() {
doTest();
}
public void testElif() {
doTest();
}
public void testElifNotIndented() {
doTest();
}
public void testExcept() {
doTest();
}
public void testExceptNotIndented() {
doTest();
}
public void testFinallyInExcept() {
doTest();
}