Search in sources :

Example 11 with MinusculeMatcher

use of com.intellij.psi.codeStyle.MinusculeMatcher in project intellij-community by JetBrains.

the class DefaultChooseByNameItemProvider method processNamesByPattern.

private static void processNamesByPattern(@NotNull final ChooseByNameBase base, @NotNull final String[] names, @NotNull final String pattern, final ProgressIndicator indicator, @NotNull final Consumer<MatchResult> consumer) {
    final MinusculeMatcher matcher = buildPatternMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
    Processor<String> processor = name -> {
        ProgressManager.checkCanceled();
        MatchResult result = matches(base, pattern, matcher, name);
        if (result != null) {
            consumer.consume(result);
        }
        return true;
    };
    if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Arrays.asList(names), indicator, false, true, processor)) {
        throw new ProcessCanceledException();
    }
}
Also used : java.util(java.util) JobLauncher(com.intellij.concurrency.JobLauncher) MinusculeMatcher(com.intellij.psi.codeStyle.MinusculeMatcher) PsiProximityComparator(com.intellij.psi.util.proximity.PsiProximityComparator) IdFilter(com.intellij.util.indexing.IdFilter) ContainerUtil(com.intellij.util.containers.ContainerUtil) NameUtil(com.intellij.psi.codeStyle.NameUtil) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) PsiElement(com.intellij.psi.PsiElement) Logger(com.intellij.openapi.diagnostic.Logger) ProgressManager(com.intellij.openapi.progress.ProgressManager) StringUtil(com.intellij.openapi.util.text.StringUtil) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) TextRange(com.intellij.openapi.util.TextRange) PsiCompiledElement(com.intellij.psi.PsiCompiledElement) ProgressIndicatorProvider(com.intellij.openapi.progress.ProgressIndicatorProvider) SmartPointerManager(com.intellij.psi.SmartPointerManager) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SmartPsiElementPointer(com.intellij.psi.SmartPsiElementPointer) Pair(com.intellij.openapi.util.Pair) FList(com.intellij.util.containers.FList) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) FindSymbolParameters(com.intellij.util.indexing.FindSymbolParameters) MinusculeMatcher(com.intellij.psi.codeStyle.MinusculeMatcher) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 12 with MinusculeMatcher

use of com.intellij.psi.codeStyle.MinusculeMatcher in project intellij-community by JetBrains.

the class GotoActionItemProvider method processActions.

private boolean processActions(String pattern, boolean everywhere, Processor<MatchedValue> consumer, DataContext dataContext) {
    JBIterable<AnAction> actions;
    if (everywhere) {
        Set<String> ids = ((ActionManagerImpl) myActionManager).getActionIds();
        actions = JBIterable.from(ids).transform(myActionManager::getAction).filter(Condition.NOT_NULL);
    } else {
        actions = JBIterable.from(myModel.myActionGroups.keySet());
    }
    MinusculeMatcher matcher = NameUtil.buildMatcher("*" + pattern, NameUtil.MatchingCaseSensitivity.NONE);
    JBIterable<ActionWrapper> actionWrappers = actions.transform(action -> {
        MatchMode mode = myModel.actionMatches(pattern, matcher, action);
        if (mode == MatchMode.NONE)
            return null;
        return new ActionWrapper(action, myModel.myActionGroups.get(action), mode, dataContext);
    }).filter(Condition.NOT_NULL);
    return processItems(pattern, actionWrappers, consumer);
}
Also used : CollectConsumer(com.intellij.util.CollectConsumer) java.util(java.util) JBIterable(com.intellij.util.containers.JBIterable) ApplyIntentionAction(com.intellij.ide.actions.ApplyIntentionAction) MinusculeMatcher(com.intellij.psi.codeStyle.MinusculeMatcher) ContainerUtil(com.intellij.util.containers.ContainerUtil) ActionFromOptionDescriptorProvider(com.intellij.ide.ui.search.ActionFromOptionDescriptorProvider) NameUtil(com.intellij.psi.codeStyle.NameUtil) SearchableOptionsRegistrarImpl(com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl) Project(com.intellij.openapi.project.Project) SearchableOptionsRegistrar(com.intellij.ide.ui.search.SearchableOptionsRegistrar) Matcher(com.intellij.util.text.Matcher) DataManager(com.intellij.ide.DataManager) ProgressManager(com.intellij.openapi.progress.ProgressManager) StringUtil(com.intellij.openapi.util.text.StringUtil) NotNullLazyValue(com.intellij.openapi.util.NotNullLazyValue) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) GotoActionModel(com.intellij.ide.util.gotoByName.GotoActionModel) OptionDescription(com.intellij.ide.ui.search.OptionDescription) Processor(com.intellij.util.Processor) OptionsTopHitProvider(com.intellij.ide.ui.OptionsTopHitProvider) NotNull(org.jetbrains.annotations.NotNull) SearchTopHitProvider(com.intellij.ide.SearchTopHitProvider) Condition(com.intellij.openapi.util.Condition) ActionManagerImpl(com.intellij.openapi.actionSystem.impl.ActionManagerImpl) MinusculeMatcher(com.intellij.psi.codeStyle.MinusculeMatcher)

Aggregations

MinusculeMatcher (com.intellij.psi.codeStyle.MinusculeMatcher)12 OptionDescription (com.intellij.ide.ui.search.OptionDescription)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 ProgressManager (com.intellij.openapi.progress.ProgressManager)3 TextRange (com.intellij.openapi.util.TextRange)3 StringUtil (com.intellij.openapi.util.text.StringUtil)3 NameUtil (com.intellij.psi.codeStyle.NameUtil)3 ContainerUtil (com.intellij.util.containers.ContainerUtil)3 java.util (java.util)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 DataManager (com.intellij.ide.DataManager)2 SearchTopHitProvider (com.intellij.ide.SearchTopHitProvider)2 ApplyIntentionAction (com.intellij.ide.actions.ApplyIntentionAction)2 OptionsTopHitProvider (com.intellij.ide.ui.OptionsTopHitProvider)2 ActionFromOptionDescriptorProvider (com.intellij.ide.ui.search.ActionFromOptionDescriptorProvider)2 SearchableOptionsRegistrar (com.intellij.ide.ui.search.SearchableOptionsRegistrar)2 SearchableOptionsRegistrarImpl (com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl)2 GotoActionModel (com.intellij.ide.util.gotoByName.GotoActionModel)2 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)2