@Override
  public boolean shouldShowProblem(@NotNull PsiErrorElement error) {
    final String description = error.getErrorDescription();
    final PsiElement parent = error.getParent();

    if (parent instanceof PsiClass && !(parent instanceof PsiCodeFragment) &&
        JavaPsiBundle.message("expected.identifier").equals(description)) {
      final PsiElement prev = error.getPrevSibling();
      if (prev instanceof PsiTypeElement) {
        final String text = prev.getText();
        if (StringUtil.startsWithChar(text, '$') && StringUtil.endsWithChar(text, '$') ||
            text.startsWith(JavaCompiledPattern.TYPED_VAR_PREFIX)) {
          // other class content variable.
          return false;
        }
      }
    }
    if (parent instanceof PsiTryStatement && JavaPsiBundle.message("expected.catch.or.finally").equals(description)) {
      // searching for naked try allowed
      return false;
    }
    final PsiElement grandParent = parent.getParent();
    if (parent instanceof PsiStatement && grandParent instanceof PsiCodeFragment) {
      final int count = PsiTreeUtil.countChildrenOfType(grandParent, PsiStatement.class);
      if (count == 1) {
        final PsiStatement statement = (PsiStatement)parent;
        if (statement instanceof PsiExpressionStatement || statement instanceof PsiDeclarationStatement) {
          // search for expression, type, annotation or symbol
          if (JavaPsiBundle.message("expected.semicolon").equals(description) && error.getNextSibling() == null) {
            // expression
            return false;
          }
          if (JavaPsiBundle.message("expected.identifier.or.type").equals(description)) {
            // annotation
            return false;
          }
          if (JavaPsiBundle.message("expected.identifier").equals(description)) {
            // type
            return false;
          }
        }
      }
    }
    else if (parent instanceof PsiReferenceParameterList && grandParent instanceof PsiJavaCodeReferenceElement) {
      final PsiElement greatGrandParent = grandParent.getParent();
      if (greatGrandParent instanceof PsiTypeElement) {
        final PsiElement greatGreatGrandParent = greatGrandParent.getParent();
        if (greatGreatGrandParent instanceof PsiDeclarationStatement &&
            PsiTreeUtil.skipWhitespacesAndCommentsBackward(greatGreatGrandParent) == null &&
            PsiTreeUtil.skipWhitespacesAndCommentsForward(greatGreatGrandParent) == null &&
            JavaPsiBundle.message("expected.gt.or.comma").equals(description)) {
          // probably less-than expression, not unfinished generic variable declaration e.g. List<String
          return false;
        }
      }
    }
    return true;
  }
@Override
  public boolean shouldShowProblem(@NotNull PsiErrorElement error)