mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-2795 Python 2.4 compatibility: Unified try/except/finally: missing inspection
This commit is contained in:
@@ -572,11 +572,22 @@ public class PyCompatibilityInspection extends PyInspection {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyAssignmentStatement(PyAssignmentStatement node) {
|
||||
public void visitPyAssignmentStatement(PyAssignmentStatement node) { // PY-2792
|
||||
if (myVersionsToProcess.contains(LanguageLevel.PYTHON24)) {
|
||||
if (node.getAssignedValue() instanceof PyConditionalExpression)
|
||||
registerProblem(node, "Python version 2.4 doesn't support this syntax.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyTryExceptStatement(PyTryExceptStatement node) { // PY-2795
|
||||
if (myVersionsToProcess.contains(LanguageLevel.PYTHON24)) {
|
||||
PyExceptPart[] excepts = node.getExceptParts();
|
||||
PyFinallyPart finallyPart = node.getFinallyPart();
|
||||
if (excepts.length != 0 && finallyPart != null)
|
||||
registerProblem(node, "Python version 2.4 doesn't support this syntax. You could use a finally block to ensure " +
|
||||
"that code is always executed, or one or more except blocks to catch specific exceptions.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,11 +307,20 @@ public class UnsupportedFeatures extends PyAnnotator {
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void visitPyAssignmentStatement(PyAssignmentStatement node) {
|
||||
public void visitPyAssignmentStatement(PyAssignmentStatement node) { // PY-2792
|
||||
if (getLanguageLevel(node) == LanguageLevel.PYTHON24) {
|
||||
if (node.getAssignedValue() instanceof PyConditionalExpression)
|
||||
getHolder().createWarningAnnotation(node, "Python version 2.4 doesn't support this syntax.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyTryExceptStatement(PyTryExceptStatement node) { // PY-2795
|
||||
if (getLanguageLevel(node) == LanguageLevel.PYTHON24) {
|
||||
PyExceptPart[] excepts = node.getExceptParts();
|
||||
PyFinallyPart finallyPart = node.getFinallyPart();
|
||||
if (excepts.length != 0 && finallyPart != null)
|
||||
getHolder().createWarningAnnotation(node, "Python version 2.4 doesn't support this syntax. You could use a finally block to ensure " +
|
||||
"that code is always executed, or one or more except blocks to catch specific exceptions.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user