void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiElement parent = element.getParent(); final PsiAnonymousClass aClass; if (parent instanceof PsiAnonymousClass) { aClass = (PsiAnonymousClass)parent; } else if (parent instanceof PsiEnumConstant) { aClass = ((PsiEnumConstant)parent).getInitializingClass(); if (aClass == null) return; } else { return; } PsiElement lBrace = aClass.getLBrace(); PsiElement rBrace = aClass.getRBrace(); if (lBrace != null && rBrace != null) { PsiElement prev = lBrace.getPrevSibling(); PsiElement start = prev instanceof PsiWhiteSpace ? prev : lBrace; Document document = aClass.getContainingFile().getViewProvider().getDocument(); if (document == null) return; int anonymousStart = start.getTextRange().getStartOffset(); int rBraceEnd = rBrace.getTextRange().getEndOffset(); document.deleteString(anonymousStart, rBraceEnd); } }