void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiMethodCallExpression sortCall = tryCast(element, PsiMethodCallExpression.class); if (sortCall == null) return; PsiMethodCallExpression collector = findSubsequentCall(sortCall, c -> false, UNORDERED_COLLECTOR, CALLS_KEEPING_SORT_ORDER::contains); if (collector == null) return; CommentTracker ct = new CommentTracker(); String replacementText = CommonClassNames.JAVA_UTIL_STREAM_COLLECTORS + ".toCollection(java.util.LinkedHashSet::new)"; PsiElement result = ct.replaceAndRestoreComments(collector, replacementText); JavaCodeStyleManager.getInstance(project).shortenClassReferences(result); }