Ref<QualifiedName> (@NotNull PyTargetExpression psi) { final PyTargetExpressionStub stub = psi.getStub(); if (stub != null) { final PyTargetExpressionStub.InitializerType initializerType = stub.getInitializerType(); if (initializerType == PyTargetExpressionStub.InitializerType.CallExpression) { return Ref.create(stub.getInitializer()); } else if (initializerType == PyTargetExpressionStub.InitializerType.Custom) { final CustomTargetExpressionStub customStub = stub.getCustomStub(CustomTargetExpressionStub.class); if (customStub != null) { final QualifiedName calleeName = customStub.getCalleeName(); return calleeName != null ? Ref.create(calleeName) : null; } } return null; } final PyExpression value = psi.findAssignedValue(); return value instanceof PyCallExpression ? Ref.create(PyPsiUtils.asQualifiedName(((PyCallExpression)value).getCallee())) : null; }