void (PsiClass aClass) { if (aClass instanceof PsiAnonymousClass || myVariableInfos.length == 0) return; PsiMethod[] constructors = aClass.getConstructors(); if (constructors.length == 0) { constructors = new PsiMethod[]{AddDefaultConstructorFix.addDefaultConstructor(aClass)}; } Map<PsiMethod, List<PsiNewExpression>> newExpressions = new HashMap<>(); for (PsiMethod constructor : constructors) { newExpressions.put(constructor, new ArrayList<>()); if (constructor.isVarArgs()) { VarargParameterInspection.convertVarargMethodToArray(constructor); } } for (PsiReference reference : ReferencesSearch.search(aClass, aClass.getUseScope()).findAll()) { if (reference.getElement().getParent() instanceof PsiMethodReferenceExpression methodRef && methodRef.isConstructor()) { LambdaRefactoringUtil.convertMethodReferenceToLambda(methodRef, false, true); } } for (PsiReference reference : ReferencesSearch.search(aClass, aClass.getUseScope()).findAll()) { PsiElement parent = reference.getElement().getParent(); if (parent instanceof PsiAnonymousClass cls) { parent = cls.getParent(); } if (parent instanceof PsiNewExpression newExpression) { PsiMethod method = newExpression.resolveConstructor(); List<PsiNewExpression> newList = newExpressions.get(method); if (newList != null) { newList.add(newExpression); } } } PsiElementFactory factory = JavaPsiFacade.getElementFactory(myProject); newExpressions.forEach((constructor, callSites) -> { fillParameterList(constructor); createAssignmentStatements(constructor); appendInitializers(constructor); for (PsiNewExpression callSite : callSites) { PsiExpressionList arguments = callSite.getArgumentList(); if (arguments != null) { for (VariableInfo info : myVariableInfos) { arguments.add(factory.createExpressionFromText(Objects.requireNonNull(info.variable.getName()), arguments)); } } } }); }