private static void tryFixSurroundContext(@NotNull PsiElement anchor) {
    if (anchor.getParent() instanceof PsiCodeBlock && anchor.getParent().getParent() instanceof PsiClassInitializer) {
      PsiElement element = anchor.getParent().getParent();
      while (element != null) {
        element = element.getPrevSibling();
        if (element instanceof PsiErrorElement &&
            ((PsiErrorElement)element).getErrorDescription().equals(JavaPsiBundle.message("expected.class.or.interface"))) {
          PsiElement prev = PsiTreeUtil.skipWhitespacesAndCommentsBackward(element);
          if (PsiUtil.isJavaToken(prev, JavaTokenType.RBRACE)) {
            prev.delete();
          }
          if (prev instanceof PsiErrorElement &&
              ((PsiErrorElement)prev).getErrorDescription().equals(JavaPsiBundle.message("expected.lbrace"))) {
            prev.replace(new LightJavaToken(anchor.getManager(), "{"));
          }
        }
      }
    }
  }
private static void tryFixSurroundContext(@NotNull PsiElement anchor)