ReduceResult (@NotNull PsiElement context) { Set<PatternTypeTestDescription> typeTestDescriptions = StreamEx.of(currentPatterns).select(PatternTypeTestDescription.class).toSet(); Set<PatternTypeTestDescription> toAdd = new HashSet<>(); Set<PsiType> existedTypes = StreamEx.of(typeTestDescriptions).map(t -> t.type()).toSet(); Set<PsiClass> visitedCovered = findMissedClasses(mySelectorType, new ArrayList<>(typeTestDescriptions), List.of(), context).coveredClasses(); boolean changed = addNewClasses(mySelectorType, visitedCovered, existedTypes, toAdd); if (!changed) { return new ReduceResult(currentPatterns, false); } Set<PatternDescription> newPatterns = combineResult(currentPatterns, Set.of(), toAdd); if (newPatterns.size() == currentPatterns.size()) { return new ReduceResult(currentPatterns, false); } return new ReduceResult(newPatterns, true); }