mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
fixed PY-11884 Missing completion for finally keyword after else statement
This commit is contained in:
@@ -308,6 +308,9 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_EXCEPT_BODY =
|
||||
psiElement().inside(psiElement(PyStatementList.class).inside(psiElement(PyExceptPart.class)));
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> IN_ELSE_BODY_OF_TRY =
|
||||
psiElement().inside(psiElement(PyStatementList.class).inside(psiElement(PyElsePart.class).inside(PyTryExceptStatement.class)));
|
||||
|
||||
private static final PsiElementPattern.Capture<PsiElement> AFTER_IF = afterStatement(psiElement(PyIfStatement.class).withLastChild(
|
||||
psiElement(PyIfPart.class)));
|
||||
private static final PsiElementPattern.Capture<PsiElement> AFTER_TRY = afterStatement(psiElement(PyTryExceptStatement.class));
|
||||
@@ -479,7 +482,7 @@ public class PyKeywordCompletionContributor extends CompletionContributor {
|
||||
CompletionType.BASIC, psiElement()
|
||||
.withLanguage(PythonLanguage.getInstance())
|
||||
.and(FIRST_ON_LINE)
|
||||
.andOr(IN_TRY_BODY, IN_EXCEPT_BODY, AFTER_TRY)
|
||||
.andOr(IN_TRY_BODY, IN_EXCEPT_BODY, AFTER_TRY, IN_ELSE_BODY_OF_TRY)
|
||||
//.andNot(RIGHT_AFTER_COLON)
|
||||
.andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL)
|
||||
,
|
||||
|
||||
8
python/testData/keywordCompletion/finallyInElse.after.py
Normal file
8
python/testData/keywordCompletion/finallyInElse.after.py
Normal file
@@ -0,0 +1,8 @@
|
||||
def f():
|
||||
try:
|
||||
a = 1
|
||||
except:
|
||||
b = 1
|
||||
else:
|
||||
c = 1
|
||||
finally:
|
||||
8
python/testData/keywordCompletion/finallyInElse.py
Normal file
8
python/testData/keywordCompletion/finallyInElse.py
Normal file
@@ -0,0 +1,8 @@
|
||||
def f():
|
||||
try:
|
||||
a = 1
|
||||
except:
|
||||
b = 1
|
||||
else:
|
||||
c = 1
|
||||
fin<caret>
|
||||
@@ -124,8 +124,8 @@ public class PythonKeywordCompletionTest extends PyTestCase {
|
||||
|
||||
public void testNoElseBeforeExcept() {
|
||||
final List<String> lookupElementStrings = doTestByText("try:\n" +
|
||||
" a = 1\n" +
|
||||
"<caret>");
|
||||
" a = 1\n" +
|
||||
"<caret>");
|
||||
assertNotNull(lookupElementStrings);
|
||||
assertDoesntContain(lookupElementStrings, "else");
|
||||
}
|
||||
@@ -169,6 +169,10 @@ public class PythonKeywordCompletionTest extends PyTestCase {
|
||||
"el<caret>").contains("else"));
|
||||
}
|
||||
|
||||
public void testFinallyInElse() { // PY-6755
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testForInComprehension() { // PY-3687
|
||||
assertContainsElements(doTestByText("L = [x fo<caret>]"), "for");
|
||||
assertContainsElements(doTestByText("L = [x <caret>]"), "for");
|
||||
|
||||
Reference in New Issue
Block a user