mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
correctly handle lastParent in 'try' statement processDeclarations()
This commit is contained in:
@@ -96,22 +96,19 @@ public class PyTryExceptStatementImpl extends PyElementImpl implements PyTryExce
|
||||
@NotNull ResolveState substitutor,
|
||||
PsiElement lastParent,
|
||||
@NotNull PsiElement place) {
|
||||
if (lastParent != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getTryStatementList().processDeclarations(processor, substitutor, null, place)) {
|
||||
final PyStatementList tryStatementList = getTryStatementList();
|
||||
if (tryStatementList != lastParent && !tryStatementList.processDeclarations(processor, substitutor, null, place)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (PyExceptBlock block : getExceptBlocks()) {
|
||||
if (!block.processDeclarations(processor, substitutor, null, place)) {
|
||||
if (block != lastParent && !block.processDeclarations(processor, substitutor, null, place)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PyStatementList elseStatementList = getElseStatementList();
|
||||
if (elseStatementList != null) {
|
||||
if (elseStatementList != null && elseStatementList != lastParent) {
|
||||
return elseStatementList.processDeclarations(processor, substitutor, null, place);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
while True:
|
||||
try:
|
||||
x
|
||||
print "a"
|
||||
finally:
|
||||
<error descr="'continue' not supported inside 'finally' clause">continue</error>
|
||||
@@ -0,0 +1,6 @@
|
||||
try:
|
||||
name = ""
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
print na<ref>me
|
||||
@@ -58,6 +58,11 @@ public class PyResolveTest extends ResolveTestCase {
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
public void testTryExceptElse() throws Exception {
|
||||
PsiElement targetElement = resolve();
|
||||
assertTrue(targetElement instanceof PyTargetExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PathManager.getHomePath() + "/plugins/python/testData/resolve/";
|
||||
|
||||
Reference in New Issue
Block a user