mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
include read of lambda default parameter value in control flow graph
This commit is contained in:
@@ -38,7 +38,15 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
public void visitPyFunction(final PyFunction node) {
|
||||
// Create node and stop here
|
||||
myBuilder.startNode(node);
|
||||
ParamHelper.walkDownParamArray(node.getParameterList().getParameters(), new ParamHelper.ParamVisitor() {
|
||||
visitDefaultParameterValues(node.getParameterList());
|
||||
|
||||
final ReadWriteInstruction instruction = ReadWriteInstruction.write(myBuilder, node, node.getName());
|
||||
myBuilder.addNode(instruction);
|
||||
myBuilder.checkPending(instruction);
|
||||
}
|
||||
|
||||
private void visitDefaultParameterValues(PyParameterList parameterList) {
|
||||
ParamHelper.walkDownParamArray(parameterList.getParameters(), new ParamHelper.ParamVisitor() {
|
||||
@Override
|
||||
public void visitNamedParameter(PyNamedParameter param, boolean first, boolean last) {
|
||||
final PyExpression defaultValue = param.getDefaultValue();
|
||||
@@ -47,10 +55,6 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final ReadWriteInstruction instruction = ReadWriteInstruction.write(myBuilder, node, node.getName());
|
||||
myBuilder.addNode(instruction);
|
||||
myBuilder.checkPending(instruction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -664,6 +668,7 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
@Override
|
||||
public void visitPyLambdaExpression(final PyLambdaExpression node) {
|
||||
myBuilder.startNode(node);
|
||||
visitDefaultParameterValues(node.getParameterList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{(lambda ii=ii: ii) for ii in range(5)}
|
||||
@@ -0,0 +1,11 @@
|
||||
0(1) element: null
|
||||
1(2) element: PyExpressionStatement
|
||||
2(3) element: PySetCompExpression
|
||||
3(4) element: PyCallExpression: range
|
||||
4(5,10) READ ACCESS: range
|
||||
5(6) element: PyTargetExpression: ii
|
||||
6(7) WRITE ACCESS: ii
|
||||
7(8) element: PyParenthesizedExpression
|
||||
8(9) element: PyLambdaExpression
|
||||
9(5,10) READ ACCESS: ii
|
||||
10() element: null
|
||||
@@ -161,6 +161,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLambdaDefaultParameter() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testQualifiedSelfReference() {
|
||||
final String testName = getTestName(false).toLowerCase();
|
||||
configureByFile(testName + ".py");
|
||||
|
||||
Reference in New Issue
Block a user