Search in sources :

Example 6 with PyTargetExpressionStub

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

the class PyStdlibTypeProvider method getNamedTupleType.

@Nullable
private static PyType getNamedTupleType(@NotNull PsiElement referenceTarget, @NotNull TypeEvalContext context, @Nullable PsiElement anchor) {
    if (referenceTarget instanceof PyTargetExpression) {
        final PyTargetExpression target = (PyTargetExpression) referenceTarget;
        final PyTargetExpressionStub stub = target.getStub();
        if (stub != null) {
            return getNamedTupleTypeFromStub(target, stub.getCustomStub(PyNamedTupleStub.class), 1);
        } else {
            return getNamedTupleTypeFromAST(target, context, 1);
        }
    } else if (referenceTarget instanceof PyFunction && anchor instanceof PyCallExpression) {
        return getNamedTupleTypeFromAST((PyCallExpression) anchor, context, 2);
    }
    return null;
}
Also used : PyTargetExpressionStub(com.jetbrains.python.psi.stubs.PyTargetExpressionStub) PyNamedTupleStub(com.jetbrains.python.psi.stubs.PyNamedTupleStub) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PyTargetExpressionStub (com.jetbrains.python.psi.stubs.PyTargetExpressionStub)6 Nullable (org.jetbrains.annotations.Nullable)4 StubElement (com.intellij.psi.stubs.StubElement)2 PyClassStub (com.jetbrains.python.psi.stubs.PyClassStub)2 ASTNode (com.intellij.lang.ASTNode)1 PsiComment (com.intellij.psi.PsiComment)1 PsiElement (com.intellij.psi.PsiElement)1 CustomTargetExpressionStub (com.jetbrains.python.psi.impl.stubs.CustomTargetExpressionStub)1 PropertyStubStorage (com.jetbrains.python.psi.stubs.PropertyStubStorage)1 PyFunctionStub (com.jetbrains.python.psi.stubs.PyFunctionStub)1 PyNamedTupleStub (com.jetbrains.python.psi.stubs.PyNamedTupleStub)1