boolean (@NotNull PsiElement base) { for (PsiElement current = base.getNextSibling(); current != null; current = current.getNextSibling()) { if (current instanceof PsiErrorElement) { return true; } } return base.getPrevSibling() instanceof PsiErrorElement; }