void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (!PsiUtil.isLanguageLevel5OrHigher(element)) { return; } final PsiElement parent = element.getParent(); if (!(parent instanceof PsiClass aClass)) { return; } for (PsiMethod constructor : aClass.getConstructors()) { constructor.delete(); } final List<PsiKeyword> keywords = PsiTreeUtil.getChildrenOfTypeAsList(aClass, PsiKeyword.class); if (keywords.isEmpty()) { return; } final PsiModifierList modifierList = aClass.getModifierList(); if (modifierList != null) { modifierList.setModifierProperty(PsiModifier.FINAL, false); modifierList.setModifierProperty(PsiModifier.ABSTRACT, false); modifierList.setModifierProperty(PsiModifier.STATIC, false); // remove redundant modifier because nested enum is implicitly static } final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); final PsiStatement statement = factory.createStatementFromText(";", element); final PsiElement token = statement.getChildren()[0]; aClass.addAfter(token, aClass.getLBrace()); final PsiKeyword newKeyword = factory.createKeyword(PsiKeyword.ENUM); keywords.get(0).replace(newKeyword); }