void () { PsiElement child = getFirstChild(); while (child instanceof PsiWhiteSpace || child instanceof PsiComment || child instanceof PsiErrorElement) { if (child instanceof PsiErrorElement && child.getFirstChild() != null && child.getFirstChild().textMatches(PsiKeyword.PACKAGE)) { child.delete(); break; } child = child.getNextSibling(); } }