correctly handle lastParent in 'try' statement processDeclarations()

This commit is contained in:
Dmitry Jemerov
2008-03-06 18:25:35 +03:00
parent 6b8fec0abd
commit 0010688019
4 changed files with 16 additions and 8 deletions
@@ -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>
+6
View File
@@ -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/";