void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (!(element instanceof PsiVariable) && !(element instanceof PsiMethod) && !(element instanceof PsiDeclarationStatement)) { element = element.getParent(); } if (element instanceof PsiParameter || element instanceof PsiRecordComponent) { JavaSharedImplUtil.normalizeBrackets((PsiVariable)element); return; } if (element instanceof PsiLocalVariable) { element = element.getParent(); if (!(element instanceof PsiDeclarationStatement)) { return; } } if (element instanceof PsiDeclarationStatement declarationStatement) { final PsiElement grandParent = element.getParent(); if (grandParent instanceof PsiForStatement) { splitMultipleDeclarationInForStatementInitialization((PsiForStatement)grandParent); } else { final PsiElement[] elements = declarationStatement.getDeclaredElements(); List<PsiVariable> psiVariables = ContainerUtil.filterIsInstance(elements, PsiVariable.class); if (!myCStyleDeclaration || elements.length != psiVariables.size() || !new SingleDeclarationNormalizer(psiVariables).normalize()) { final PsiVariable variable = (PsiVariable)elements[0]; variable.normalizeDeclaration(); for (int i = 1; i < elements.length; i++) { declarationStatement = PsiTreeUtil.getNextSiblingOfType(declarationStatement, PsiDeclarationStatement.class); assert declarationStatement != null; JavaSharedImplUtil.normalizeBrackets((PsiVariable)declarationStatement.getDeclaredElements()[0]); } } } } else if (element instanceof PsiField) { PsiField field = DeclarationSearchUtils.findFirstFieldInDeclaration((PsiField)element); assert field != null; PsiField nextField = field; int count = 0; List<PsiVariable> psiFields = new ArrayList<>(); while (nextField != null) { count++; psiFields.add(nextField); nextField = DeclarationSearchUtils.findNextFieldInDeclaration(nextField); } if (!myCStyleDeclaration || !new SingleDeclarationNormalizer(psiFields).normalize()) { field.normalizeDeclaration(); for (int i = 1; i < count; i++) { field = PsiTreeUtil.getNextSiblingOfType(field, PsiField.class); assert field != null; JavaSharedImplUtil.normalizeBrackets(field); } } } else if (element instanceof PsiMethod method) { final PsiTypeElement returnTypeElement = method.getReturnTypeElement(); if (returnTypeElement == null) { return; } final PsiType returnType = method.getReturnType(); if (returnType == null) { return; } final PsiTypeElement typeElement = JavaPsiFacade.getElementFactory(project).createTypeElement(returnType); CommentTracker ct = new CommentTracker(); PsiElement replacement = ct.replaceAndRestoreComments(returnTypeElement, typeElement); JavaCodeStyleManager.getInstance(project).shortenClassReferences(replacement); PsiElement child = method.getParameterList(); while (child != null && !(child instanceof PsiCodeBlock)) { final PsiElement elementToDelete = child; child = PsiTreeUtil.skipWhitespacesAndCommentsForward(child); if (elementToDelete instanceof PsiJavaToken) { final IElementType tokenType = ((PsiJavaToken)elementToDelete).getTokenType(); if (JavaTokenType.LBRACKET.equals(tokenType) || JavaTokenType.RBRACKET.equals(tokenType)) { elementToDelete.delete(); } } else if (elementToDelete instanceof PsiAnnotation) { elementToDelete.delete(); } } } }