List<GroupExhaustiveness> (@NotNull PsiType recordType, @NotNull List<? extends PsiType> recordTypes, @NotNull MultiMap<PsiType, List<PsiPattern>> groupedByType) { MultiMap<PsiType, List<PsiPattern>> deconstructionGroups = getDeconstructionGroupsByType(groupedByType); return ContainerUtil.map(deconstructionGroups.entrySet(), deconstructionGroup -> { if (ContainerUtil.exists(deconstructionGroup.getValue(), t -> t == null || t.isEmpty())) { return new GroupExhaustiveness(deconstructionGroup.getKey(), RecordExhaustivenessResult.createNotBeAdded(), deconstructionGroup.getValue()); } List<PsiPattern> firstElements = ContainerUtil.map(deconstructionGroup.getValue(), it -> it.get(0)); if (ContainerUtil.exists(firstElements, pattern -> pattern instanceof PsiDeconstructionPattern)) { RecordExhaustivenessResult nestedResult = checkRecordExhaustiveness(firstElements); if (!nestedResult.isExhaustive()) { //support only first level deconstruction if (nestedResult.canBeAdded() && nestedResult.missedBranchesByType.size() == 1) { RecordExhaustivenessResult result = RecordExhaustivenessResult.createNotExhaustiveResult(); result.addNewBranch(recordType, null, recordTypes); return new GroupExhaustiveness(deconstructionGroup.getKey(), result, deconstructionGroup.getValue()); } else { return new GroupExhaustiveness(deconstructionGroup.getKey(), RecordExhaustivenessResult.createNotBeAdded(), deconstructionGroup.getValue()); } } } RecordExhaustivenessResult result = findExhaustiveInGroup( recordType, dropFirst(recordTypes), ContainerUtil.map(deconstructionGroup.getValue(), PatternHighlightingModelJava20Preview::dropFirst) ); return new GroupExhaustiveness(deconstructionGroup.getKey(), result, deconstructionGroup.getValue()); }); }