Stream<PsiAnnotation> (@NotNull PsiModifierListOwner listOwner, @NotNull Collection<String> annotations) { Stream<PsiAnnotation> directAnnotations = Stream.of(AnnotationUtil.findAnnotations(listOwner, annotations)); Stream<PsiClass> lazyResolvedAnnotations = Stream.generate(() -> getResolvedClassesInAnnotationsList(listOwner)).limit(1) .flatMap(it -> it.stream()); Stream<PsiAnnotation> metaAnnotations = lazyResolvedAnnotations .flatMap(psiClass -> annotations.stream() .map(annotationFQN -> metaAnnotationCached(psiClass, annotationFQN))) .filter(Objects::nonNull); return Stream.concat(directAnnotations, metaAnnotations); }