List<String> (@NotNull ChooseByNameViewModel base, String @NotNull [] names, @NotNull String pattern) { boolean preferStartMatches = pattern.startsWith("*"); pattern = convertToMatchingPattern(base, pattern); if (pattern.isEmpty() && !base.canShowListForEmptyPattern()) return Collections.emptyList(); final List<String> filtered = new ArrayList<>(); processNamesByPattern(base, names, pattern, ProgressIndicatorProvider.getGlobalProgressIndicator(), result -> { synchronized (filtered) { filtered.add(result.elementName); } }, preferStartMatches); synchronized (filtered) { return filtered; } }