Java 类com.intellij.util.AdapterProcessor 实例源码

项目:intellij-ce-playground    文件:ReplaceInProjectManager.java   
@Override
public UsageSearcher create() {
  return new UsageSearcher() {

    @Override
    public void generate(@NotNull final Processor<Usage> processor) {
      try {
        myIsFindInProgress = true;

        FindInProjectUtil.findUsages(myFindModelCopy, myProject,
                                     new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER),
                                     myProcessPresentation);
      }
      finally {
        myIsFindInProgress = false;
      }
    }
  };
}
项目:tools-idea    文件:ReplaceInProjectManager.java   
@Override
public UsageSearcher create() {
  return new UsageSearcher() {

    @Override
    public void generate(@NotNull final Processor<Usage> processor) {
      try {
        myIsFindInProgress = true;

        FindInProjectUtil.findUsages(myFindModelCopy, myPsiDirectory, myProject,
                                     true, new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER),
                                     myProcessPresentation);
      }
      finally {
        myIsFindInProgress = false;
      }
    }
  };
}
项目:consulo    文件:ReplaceInProjectManager.java   
@Override
public UsageSearcher create() {
  return new UsageSearcher() {

    @Override
    public void generate(@Nonnull final Processor<Usage> processor) {
      try {
        myIsFindInProgress = true;

        FindInProjectUtil
                .findUsages(myFindModelCopy, myProject, new AdapterProcessor<>(processor, UsageInfo2UsageAdapter.CONVERTER), myProcessPresentation);
      }
      finally {
        myIsFindInProgress = false;
      }
    }
  };
}
项目:intellij-ce-playground    文件:SearchInBuildFilesHyperlink.java   
@Override
protected void execute(@NotNull final Project project) {
  FindManager findManager = FindManager.getInstance(project);
  UsageViewManager usageViewManager = UsageViewManager.getInstance(project);

  FindModel findModel = (FindModel)findManager.getFindInProjectModel().clone();
  findModel.setStringToFind(myTextToFind);
  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)findModel.clone();

  UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(findModel.isOpenInNewTabEnabled(), findModelCopy);
  boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
  final FindUsagesProcessPresentation processPresentation =
    FindInProjectUtil.setupProcessPresentation(project, showPanelIfOnlyOneUsage, presentation);
  UsageTarget usageTarget = new FindInProjectUtil.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);
          //noinspection ConstantConditions
          FindInProjectUtil.findUsages(findModelCopy, project, consumer, processPresentation);
        }
      };
    }
  }, processPresentation, presentation, null);
}
项目:tools-idea    文件:FindInProjectManager.java   
public void findInProject(@NotNull DataContext dataContext) {
  final boolean isOpenInNewTabEnabled;
  final boolean[] toOpenInNewTab = new boolean[1];
  Content selectedContent = UsageViewManager.getInstance(myProject).getSelectedContent(true);
  if (selectedContent != null && selectedContent.isPinned()) {
    toOpenInNewTab[0] = true;
    isOpenInNewTabEnabled = false;
  }
  else {
    toOpenInNewTab[0] = myToOpenInNewTab;
    isOpenInNewTabEnabled = UsageViewManager.getInstance(myProject).getReusableContentsCount() > 0;
  }

  final FindManager findManager = FindManager.getInstance(myProject);
  final FindModel findModel = (FindModel) findManager.getFindInProjectModel().clone();
  findModel.setReplaceState(false);
  findModel.setOpenInNewTabVisible(true);
  findModel.setOpenInNewTabEnabled(isOpenInNewTabEnabled);
  findModel.setOpenInNewTab(toOpenInNewTab[0]);
  FindInProjectUtil.setDirectoryName(findModel, dataContext);

  Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  FindUtil.initStringToFindWithSelection(findModel, editor);

  findManager.showFindDialog(findModel, new Runnable() {
    @Override
    public void run() {
      findModel.setOpenInNewTabVisible(false);
      final PsiDirectory psiDirectory = FindInProjectUtil.getPsiDirectory(findModel, myProject);
      if (findModel.getDirectoryName() != null && psiDirectory == null){
        return;
      }
      if (isOpenInNewTabEnabled) {
        myToOpenInNewTab = toOpenInNewTab[0] = findModel.isOpenInNewTab();
      }

      com.intellij.usages.UsageViewManager manager = com.intellij.usages.UsageViewManager.getInstance(myProject);

      if (manager == null) return;
      findManager.getFindInProjectModel().copyFrom(findModel);
      final FindModel findModelCopy = (FindModel)findModel.clone();
      final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(myToOpenInNewTab, findModelCopy);
      final boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();

      final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation);
      UsageTarget usageTarget = StringUtil.isEmpty(findModel.getStringToFind()) ? createFileByTypeTarget(findModel)
                                                       : new FindInProjectUtil.StringUsageTarget(findModel.getStringToFind());
      manager.searchAndShowUsages(new UsageTarget[] {usageTarget},
        new Factory<UsageSearcher>() {
          @Override
          public UsageSearcher create() {
            return new UsageSearcher() {
              @Override
              public void generate(@NotNull final Processor<Usage> processor) {
                myIsFindInProgress = true;

                try {
                  AdapterProcessor<UsageInfo, Usage> consumer = new AdapterProcessor<UsageInfo, Usage>(processor, UsageInfo2UsageAdapter.CONVERTER);
                  FindInProjectUtil.findUsages(findModelCopy, psiDirectory, myProject, true, consumer, processPresentation);
                }
                finally {
                  myIsFindInProgress = false;
                }
              }
            };
          }
        },
        processPresentation,
        presentation,
        null
      );
    }
  });
  findModel.setOpenInNewTabVisible(false);
}
项目:emberjs-plugin    文件:GotoEmberAction.java   
private Collection<Usage> getEmberUsages(Project project, DataContext dataContext, FindModel findModel) {

        FindInProjectUtil.setDirectoryName(findModel, dataContext);

        CommonProcessors.CollectProcessor<Usage> collectProcessor = new CommonProcessors.CollectProcessor<Usage>();

        PsiDirectory directory = PsiManager.getInstance(project).findDirectory(project.getBaseDir());
        FindInProjectUtil.findUsages(findModel, directory, project,
                true, new AdapterProcessor<UsageInfo, Usage>(collectProcessor, UsageInfo2UsageAdapter.CONVERTER), new FindUsagesProcessPresentation());


        return collectProcessor.getResults();
    }