void (@NotNull PsiMethod method) { if (!MethodUtils.isCopyConstructor(method)) { return; } final PsiClass aClass = method.getContainingClass(); if (aClass == null) { return; } final List<PsiField> fields = new ArrayList<>(ContainerUtil.filter(aClass.getFields(), f -> !f.hasModifierProperty(PsiModifier.STATIC) && !f.hasModifierProperty(PsiModifier.TRANSIENT) && (!f.hasModifierProperty(PsiModifier.FINAL) || f.getInitializer() == null))); if (fields.isEmpty()) return; final PsiParameter parameter = Objects.requireNonNull(method.getParameterList().getParameter(0)); final List<PsiField> assignedFields = new SmartList<>(); final Set<PsiMethod> methodsOneLevelDeep = new HashSet<>(); if (!PsiTreeUtil.processElements(method, e -> collectAssignedFields(e, parameter, methodsOneLevelDeep, assignedFields))) { return; } if (aClass.isRecord() && ContainerUtil.exists(methodsOneLevelDeep, m -> JavaPsiRecordUtil.isCanonicalConstructor(m))) { return; } for (PsiMethod calledMethod : methodsOneLevelDeep) { if (!PsiTreeUtil.processElements(calledMethod, e -> collectAssignedFields(e, null, null, assignedFields))) { return; } } for (PsiField assignedField : assignedFields) { if (aClass == PsiUtil.resolveClassInClassTypeOnly(assignedField.getType())) { return; } } fields.removeAll(assignedFields); if (fields.isEmpty()) { return; } registerMethodError(method, fields); }