boolean (@NotNull PsiElement contextElement) { return StreamEx .iterate(contextElement, PsiElement::getPrevSibling) .takeWhile(Objects::nonNull) .limit(3) .allMatch(psi -> psi instanceof PsiErrorElement || psi.textMatches(".")); }