List<PyTargetExpression> (@NotNull Project project, Editor editor, PsiFile file) { final int offset = TargetElementUtilBase.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()); final PyReferenceOwner elementAtCaret = PsiTreeUtil.getParentOfType(file.findElementAt(offset), PyReferenceExpression.class, PyTargetExpression.class); if (elementAtCaret == null) { return Collections.emptyList(); } final ProjectFileIndex index = ProjectFileIndex.getInstance(project); final TypeEvalContext typeEvalContext = TypeEvalContext.codeAnalysis(project, file); final PyResolveContext resolveContext = PyResolveContext.defaultContext(typeEvalContext); // TODO filter out targets defined in stubs return StreamEx.of(resolveReferenceAugAssignmentsAware(elementAtCaret, resolveContext, new HashSet<>())) .select(PyTargetExpression.class) .filter(target -> { VirtualFile dir = target.getContainingFile().getOriginalFile().getVirtualFile(); return dir != null && !index.isInLibraryClasses(dir); }) .filter(target -> canBeAnnotated(target)) .filter(target -> !isAnnotated(target, typeEvalContext)) .toList(); }