List<MatchResult> (@NotNull ChooseByNameViewModel base, @NotNull FindSymbolParameters parameters, @NotNull ProgressIndicator indicator, @Nullable Supplier<String[]> allNamesProducer, @NotNull String namePattern, boolean preferStartMatches) { List<MatchResult> namesList = new ArrayList<>(); final CollectConsumer<MatchResult> collect = new SynchronizedCollectConsumer<>(namesList); ChooseByNameModel model = base.getModel(); if (model instanceof ChooseByNameModelEx) { indicator.checkCanceled(); long started = System.currentTimeMillis(); String fullPattern = parameters.getCompletePattern(); MinusculeMatcher matcher = buildPatternMatcher(namePattern, preferStartMatches); ((ChooseByNameModelEx)model).processNames(sequence -> { indicator.checkCanceled(); MatchResult result = matches(base, fullPattern, matcher, sequence); if (result != null) { collect.consume(result); return true; } return false; }, parameters); if (LOG.isDebugEnabled()) { LOG.debug("loaded + matched:"+ (System.currentTimeMillis() - started)+ "," + collect.getResult().size()); } } else { if (allNamesProducer == null) { throw new IllegalArgumentException("Need to specify allNamesProducer when using a model which isn't a ChooseByNameModelEx"); } String[] names = allNamesProducer.get(); long started = System.currentTimeMillis(); processNamesByPattern(base, names, namePattern, indicator, collect, preferStartMatches); if (LOG.isDebugEnabled()) { LOG.debug("matched:"+ (System.currentTimeMillis() - started)+ "," + names.length); } } synchronized (collect) { return new ArrayList<>(namesList); } }