public static boolean hasErrorElements(@NotNull PsiElement element) {
    Ref<Boolean> result = new Ref<>(false);
    PsiWalkingState.processAll(element, el -> {
      if (el instanceof PsiErrorElement) {
        result.set(true);
        return false;
      } else return true;
    });
    return result.get();
  }
public static boolean hasErrorElements(@NotNull PsiElement element)