void (@NotNull PsiElement element) { StringBuilder err = null; int s = 0; String text = element.getText(); for (PsiErrorElement error : SyntaxTraverser.psiTraverser().withRoot(element).filter(PsiErrorElement.class)) { if (err == null) err = new StringBuilder(); TextRange r = error.getTextRange(); if (r.getStartOffset() < s) continue; err.append(text, s, r.getStartOffset()).append("<error desc=\""); err.append(error.getErrorDescription()).append("\">"); err.append(error.getText()).append("</error>"); s = r.getEndOffset(); } if (err == null) return; err.append(text, s, text.length()); UsefulTestCase.assertSameLines(text, err.toString()); }