Search in sources :

Example 1 with AdapterProcessor

use of com.intellij.util.AdapterProcessor in project android by JetBrains.

the class SearchInBuildFilesHyperlink method searchInBuildFiles.

public static void searchInBuildFiles(@NotNull String text, @NotNull final Project project) {
    FindManager findManager = FindManager.getInstance(project);
    UsageViewManager usageViewManager = UsageViewManager.getInstance(project);
    FindModel findModel = findManager.getFindInProjectModel().clone();
    findModel.setStringToFind(text);
    findModel.setReplaceState(false);
    findModel.setOpenInNewTabVisible(true);
    findModel.setOpenInNewTabEnabled(true);
    findModel.setOpenInNewTab(true);
    findModel.setFileFilter(SdkConstants.FN_BUILD_GRADLE);
    findManager.getFindInProjectModel().copyFrom(findModel);
    final FindModel findModelCopy = findModel.clone();
    UsageViewPresentation presentation = setupViewPresentation(findModel.isOpenInNewTabEnabled(), findModelCopy);
    boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
    final FindUsagesProcessPresentation processPresentation = setupProcessPresentation(project, showPanelIfOnlyOneUsage, presentation);
    UsageTarget usageTarget = new StringUsageTarget(project, findModel);
    usageViewManager.searchAndShowUsages(new UsageTarget[] { usageTarget }, new Factory<UsageSearcher>() {

        @Override
        public UsageSearcher create() {
            return new UsageSearcher() {

                @Override
                public void generate(@NotNull final Processor<Usage> processor) {
                    AdapterProcessor<UsageInfo, Usage> consumer = new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER);
                    findUsages(findModelCopy, project, consumer, processPresentation);
                }
            };
        }
    }, processPresentation, presentation, null);
}
Also used : FindModel(com.intellij.find.FindModel) FindManager(com.intellij.find.FindManager) AdapterProcessor(com.intellij.util.AdapterProcessor) UsageInfo(com.intellij.usageView.UsageInfo)

Aggregations

FindManager (com.intellij.find.FindManager)1 FindModel (com.intellij.find.FindModel)1 UsageInfo (com.intellij.usageView.UsageInfo)1 AdapterProcessor (com.intellij.util.AdapterProcessor)1