Search in sources :

Example 1 with PyNamedTupleStub

use of com.jetbrains.python.psi.stubs.PyNamedTupleStub in project intellij-community by JetBrains.

the class PyStubsTest method doTestNamedTuple.

private void doTestNamedTuple(@NotNull String expectedName, @NotNull List<String> expectedFields, @NotNull QualifiedName expectedCalleeName) {
    final PyFile file = getTestFile();
    final PyTargetExpression attribute = file.findTopLevelAttribute("nt");
    assertNotNull(attribute);
    final PyNamedTupleStub stub = attribute.getStub().getCustomStub(PyNamedTupleStub.class);
    assertNotNull(stub);
    assertEquals(expectedCalleeName, stub.getCalleeName());
    final PyType typeFromStub = TypeEvalContext.codeInsightFallback(myFixture.getProject()).getType(attribute);
    doTestNamedTuple(expectedName, expectedFields, typeFromStub);
    assertNotParsed(file);
    final FileASTNode astNode = file.getNode();
    assertNotNull(astNode);
    final PyType typeFromAst = TypeEvalContext.userInitiated(myFixture.getProject(), file).getType(attribute);
    doTestNamedTuple(expectedName, expectedFields, typeFromAst);
}
Also used : FileASTNode(com.intellij.lang.FileASTNode) PyType(com.jetbrains.python.psi.types.PyType) PyNamedTupleStub(com.jetbrains.python.psi.stubs.PyNamedTupleStub)

Aggregations

FileASTNode (com.intellij.lang.FileASTNode)1 PyNamedTupleStub (com.jetbrains.python.psi.stubs.PyNamedTupleStub)1 PyType (com.jetbrains.python.psi.types.PyType)1