use of com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl in project intellij-community by JetBrains.
the class GotoActionItemProvider method processOptions.
private boolean processOptions(String pattern, Processor<MatchedValue> consumer, DataContext dataContext) {
Map<String, String> map = myModel.getConfigurablesNames();
SearchableOptionsRegistrarImpl registrar = (SearchableOptionsRegistrarImpl) SearchableOptionsRegistrar.getInstance();
List<Comparable> options = ContainerUtil.newArrayList();
final Set<String> words = registrar.getProcessedWords(pattern);
Set<OptionDescription> optionDescriptions = null;
final String actionManagerName = myActionManager.getComponentName();
for (String word : words) {
final Set<OptionDescription> descriptions = registrar.getAcceptableDescriptions(word);
if (descriptions != null) {
for (Iterator<OptionDescription> iterator = descriptions.iterator(); iterator.hasNext(); ) {
OptionDescription description = iterator.next();
if (actionManagerName.equals(description.getPath())) {
iterator.remove();
}
}
if (!descriptions.isEmpty()) {
if (optionDescriptions == null) {
optionDescriptions = descriptions;
} else {
optionDescriptions.retainAll(descriptions);
}
}
} else {
optionDescriptions = null;
break;
}
}
if (!StringUtil.isEmptyOrSpaces(pattern)) {
Matcher matcher = NameUtil.buildMatcher("*" + pattern).build();
if (optionDescriptions == null)
optionDescriptions = ContainerUtil.newTroveSet();
for (Map.Entry<String, String> entry : map.entrySet()) {
if (matcher.matches(entry.getValue())) {
optionDescriptions.add(new OptionDescription(null, entry.getKey(), entry.getValue(), null, entry.getValue()));
}
}
}
if (optionDescriptions != null && !optionDescriptions.isEmpty()) {
Set<String> currentHits = new HashSet<>();
for (Iterator<OptionDescription> iterator = optionDescriptions.iterator(); iterator.hasNext(); ) {
OptionDescription description = iterator.next();
final String hit = description.getHit();
if (hit == null || !currentHits.add(hit.trim())) {
iterator.remove();
}
}
for (OptionDescription description : optionDescriptions) {
for (ActionFromOptionDescriptorProvider converter : ActionFromOptionDescriptorProvider.EP.getExtensions()) {
AnAction action = converter.provide(description);
if (action != null)
options.add(new ActionWrapper(action, null, MatchMode.NAME, dataContext));
options.add(description);
}
}
}
return processItems(pattern, JBIterable.from(options), consumer);
}
Aggregations