ConstructorSimplifier (@NotNull PsiMethod ctor) { if (!JavaPsiRecordUtil.isExplicitCanonicalConstructor(ctor)) return null; PsiCodeBlock body = ctor.getBody(); if (body == null) return null; PsiIdentifier nameIdentifier = ctor.getNameIdentifier(); if (nameIdentifier == null) return null; PsiRecordComponent[] components = Objects.requireNonNull(ctor.getContainingClass()).getRecordComponents(); PsiParameter[] parameters = ctor.getParameterList().getParameters(); PsiAnnotation.TargetType[] targets = {PsiAnnotation.TargetType.PARAMETER, PsiAnnotation.TargetType.TYPE_USE}; if (!EntryStream.zip(components, parameters) .mapKeys(c -> ContainerUtil.filter(c.getAnnotations(), anno -> AnnotationTargetUtil.findAnnotationTarget(anno, targets) != null)) .mapValues(p -> Arrays.asList(p.getAnnotations())) .allMatch((compAnnotations, paramAnnotations) -> compAnnotations.size() == paramAnnotations.size() && EntryStream.zip(compAnnotations, paramAnnotations).allMatch(PsiEquivalenceUtil::areElementsEquivalent))) { return null; } PsiStatement[] statements = body.getStatements(); int assignedCount = getAssignedComponentsCount(components, parameters, statements); if (statements.length == components.length && assignedCount == components.length && ctor.getModifierList().getAnnotations().length == 0 && ctor.getDocComment() == null) { return new RemoveRedundantCtorSimplifier(); } if (PsiUtil.findReturnStatements(body).length > 0) return null; if (assignedCount != components.length) { return null; } return new MakeCtorCompactSimplifier(); }