protected abstract void updateText(boolean isReturn);
<<<<<<< HEAD
protected boolean isTypeDefined(PyExpression problemElement) {
=======
private static boolean isTypeUndefined(PyExpression problemElement) {
final TypeEvalContext context = TypeEvalContext.fastStubOnly(problemElement.getContainingFile());
final PyType type = context.getType(problemElement);
if (type == null || type instanceof PyReturnTypeReference || type instanceof PyDynamicallyEvaluatedType) {
PsiReference reference = problemElement.getReference();
if (problemElement instanceof PyQualifiedExpression) {
final PyExpression qualifier = ((PyQualifiedExpression)problemElement).getQualifier();
if (qualifier != null && !qualifier.getText().equals(PyNames.CANONICAL_SELF)) reference = qualifier.getReference();
}
if (isDefinedInDocstring(problemElement, reference)) return false;
return !isDefinedInAnnotation(problemElement, reference);
}
return false;
}
private static boolean isDefinedInAnnotation(PyExpression problemElement, PsiReference reference) {
if (LanguageLevel.forElement(problemElement).isOlderThan(LanguageLevel.PYTHON30)) {
return false;
}
final PsiElement resolved = reference != null? reference.resolve() : null;
PyParameter parameter = getParameter(problemElement, resolved);
if (parameter instanceof PyNamedParameter && (((PyNamedParameter)parameter).getAnnotation() != null)) return true;
if (resolved instanceof PyTargetExpression) { // return type
final PyExpression assignedValue = ((PyTargetExpression)resolved).findAssignedValue();
if (assignedValue instanceof PyCallExpression) {
final PyExpression callee = ((PyCallExpression)assignedValue).getCallee();
if (callee != null) {
final PsiReference psiReference = callee.getReference();
if (psiReference != null && psiReference.resolve() == null) return false;
}
final Callable callable = ((PyCallExpression)assignedValue).resolveCalleeFunction(getResolveContext(problemElement));
if (callable instanceof PyFunction && ((PyFunction)callable).getAnnotation() != null) return true;
}
}
>>>>>>> 0f4a97b4080b6f090e246cf1a0c66bde3ae2f044
return false;
}
|