boolean (@NotNull PsiErrorElement element) { String description = element.getErrorDescription(); if (description.equals(JavaPsiBundle.message("expected.semicolon"))) { PsiElement parent = element.getParent(); if (parent instanceof PsiExpressionStatement && !PsiUtil.isStatement(parent)) { // unterminated expression statement which is not a statement at all: // let's report it as not-a-statement instead // (see HighlightUtil.checkNotAStatement); it's more visible and provides // more useful fixes. return false; } else { // reporting missing semicolons after an unclosed string literal is not useful. if (isAfterUnclosedStringLiteral(element)) return false; } } else if (description.equals(JavaPsiBundle.message("expected.comma.or.rparen"))) { if (isAfterUnclosedStringLiteral(element)) return false; } else if (description.equals(JavaPsiBundle.message("expected.class.or.interface"))) { String text = element.getText(); if ((text.equals(PsiKeyword.SEALED) || text.equals(PsiKeyword.NON_SEALED)) && PsiTreeUtil.skipWhitespacesAndCommentsForward(element) instanceof PsiClass) { return false; } } return true; }