boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof PyFile)) { return false; } PsiElement elementAt = PyUtil.findNonWhitespaceAtOffset(file, editor.getCaretModel().getOffset()); PyExpression problemElement = PsiTreeUtil.getParentOfType(elementAt, PyReferenceExpression.class); if (problemElement == null) return false; if (problemElement.getParent() instanceof PyWithItem) return false; final PyExpression qualifier = ((PyQualifiedExpression)problemElement).getQualifier(); if (qualifier != null && !qualifier.getText().equals(PyNames.CANONICAL_SELF)) { problemElement = qualifier; } final PsiReference reference = problemElement.getReference(); if (problemElement.getParent() instanceof PyCallExpression || PsiTreeUtil.getParentOfType(problemElement, PyComprehensionElement.class) != null || PsiTreeUtil.getParentOfType(problemElement, PyLambdaExpression.class) != null || PsiTreeUtil.getParentOfType(problemElement, PyGeneratorExpression.class) != null || (reference != null && reference.resolve() == null)) { return false; } final PyType type = TypeEvalContext.codeAnalysis(file.getProject(), file).getType(problemElement); return type == null; }