void (UsageInfo @NotNull [] usages) { renameMembers(usages); PsiClass psiClass = myRecordCandidate.getPsiClass(); PsiMethod canonicalCtor = myRecordCandidate.getCanonicalConstructor(); Map<PsiField, FieldAccessorCandidate> fieldAccessors = myRecordCandidate.getFieldAccessors(); RecordBuilder recordBuilder = new RecordBuilder(psiClass); PsiIdentifier classIdentifier = null; PsiElement nextElement = psiClass.getFirstChild(); while (nextElement != null) { if (nextElement instanceof PsiKeyword && JavaTokenType.CLASS_KEYWORD.equals(((PsiKeyword)nextElement).getTokenType())) { recordBuilder.addRecordDeclaration(); } else if (nextElement instanceof PsiIdentifier) { classIdentifier = (PsiIdentifier)nextElement; recordBuilder.addPsiElement(classIdentifier); } else if (nextElement instanceof PsiTypeParameterList) { recordBuilder.addPsiElement(nextElement); if (PsiTreeUtil.skipWhitespacesAndCommentsBackward(nextElement) == classIdentifier) { recordBuilder.addRecordHeader(canonicalCtor, fieldAccessors); classIdentifier = null; } } else if (nextElement instanceof PsiModifierList modifierList) { recordBuilder.addModifierList(modifierList); } else if (nextElement instanceof PsiField psiField) { psiField.normalizeDeclaration(); if (fieldAccessors.containsKey(psiField)) { nextElement = PsiTreeUtil.skipWhitespacesForward(nextElement); continue; } recordBuilder.addPsiElement(nextElement); } else if (nextElement instanceof PsiMethod) { if (nextElement == canonicalCtor) { recordBuilder.addCanonicalCtor(canonicalCtor); } else { FieldAccessorCandidate fieldAccessorCandidate = getFieldAccessorCandidate(fieldAccessors, (PsiMethod)nextElement); if (fieldAccessorCandidate == null) { recordBuilder.addPsiElement(nextElement); } else { recordBuilder.addFieldAccessor(fieldAccessorCandidate); } } } else { recordBuilder.addPsiElement(nextElement); } nextElement = nextElement.getNextSibling(); } CallMatcher redundantObjectMethods = findRedundantObjectMethods(); PsiClass result = (PsiClass)psiClass.replace(recordBuilder.build()); tryToCompactCanonicalCtor(result); removeRedundantObjectMethods(result, redundantObjectMethods); generateJavaDocForDocumentedFields(result); CodeStyleManager.getInstance(myProject).reformat(result); }