PsiType (@NotNull PsiTypeElement typeElement, @NotNull PsiElement anchor, @Nullable PsiAnnotation stopAt) { PsiType type = typeElement.getType(); boolean ellipsisType = type instanceof PsiEllipsisType; List<PsiAnnotation[]> allAnnotations = collectAnnotations(anchor, stopAt); if (allAnnotations == null) return null; for (int i = 0, size = allAnnotations.size(); i < size; i++) { type = ((ellipsisType && i == size - 1) ? new PsiEllipsisType(type) : type.createArrayType()) .annotate(TypeAnnotationProvider.Static.create(allAnnotations.get(i))); } return type; }