mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
visit type annotations in control flow builder
This commit is contained in:
@@ -38,8 +38,12 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
public void visitPyFunction(final PyFunction node) {
|
||||
// Create node and stop here
|
||||
myBuilder.startNode(node);
|
||||
visitDefaultParameterValues(node.getParameterList());
|
||||
visitParameterListExpressions(node.getParameterList());
|
||||
visitDecorators(node.getDecoratorList());
|
||||
final PyAnnotation annotation = node.getAnnotation();
|
||||
if (annotation != null) {
|
||||
annotation.accept(this);
|
||||
}
|
||||
|
||||
final ReadWriteInstruction instruction = ReadWriteInstruction.write(myBuilder, node, node.getName());
|
||||
myBuilder.addNode(instruction);
|
||||
@@ -54,7 +58,7 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
private void visitDefaultParameterValues(PyParameterList parameterList) {
|
||||
private void visitParameterListExpressions(PyParameterList parameterList) {
|
||||
ParamHelper.walkDownParamArray(parameterList.getParameters(), new ParamHelper.ParamVisitor() {
|
||||
@Override
|
||||
public void visitNamedParameter(PyNamedParameter param, boolean first, boolean last) {
|
||||
@@ -62,6 +66,10 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
if (defaultValue != null) {
|
||||
defaultValue.accept(PyControlFlowBuilder.this);
|
||||
}
|
||||
final PyAnnotation annotation = param.getAnnotation();
|
||||
if (annotation != null) {
|
||||
annotation.accept(PyControlFlowBuilder.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -678,7 +686,7 @@ public class PyControlFlowBuilder extends PyRecursiveElementVisitor {
|
||||
@Override
|
||||
public void visitPyLambdaExpression(final PyLambdaExpression node) {
|
||||
myBuilder.startNode(node);
|
||||
visitDefaultParameterValues(node.getParameterList());
|
||||
visitParameterListExpressions(node.getParameterList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
def foo(x: str) -> list:
|
||||
expr = x
|
||||
@@ -0,0 +1,6 @@
|
||||
0(1) element: null
|
||||
1(2) element: PyFunction('foo')
|
||||
2(3) READ ACCESS: str
|
||||
3(4) READ ACCESS: list
|
||||
4(5) WRITE ACCESS: foo
|
||||
5() element: null
|
||||
@@ -9,6 +9,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ControlFlowCache;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.fixtures.LightMarkedTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
@@ -173,6 +174,16 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase {
|
||||
public void testSetComprehension() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeAnnotations() {
|
||||
setLanguageLevel(LanguageLevel.PYTHON30);
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
setLanguageLevel(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void testQualifiedSelfReference() {
|
||||
final String testName = getTestName(false).toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user