コード例 #1
0
  private void findUsagesInEditor(
      @NotNull UsageInfoToUsageConverter.TargetElementsDescriptor descriptor,
      @NotNull FindUsagesHandler handler,
      @NotNull PsiFile scopeFile,
      @NotNull FileSearchScope direction,
      @NotNull final FindUsagesOptions findUsagesOptions,
      @NotNull FileEditor fileEditor) {
    initLastSearchElement(findUsagesOptions, descriptor);

    clearStatusBar();

    final FileEditorLocation currentLocation = fileEditor.getCurrentLocation();

    final UsageSearcher usageSearcher =
        createUsageSearcher(descriptor, handler, findUsagesOptions, scopeFile);
    AtomicBoolean usagesWereFound = new AtomicBoolean();

    Usage fUsage =
        findSiblingUsage(usageSearcher, direction, currentLocation, usagesWereFound, fileEditor);

    if (fUsage != null) {
      fUsage.navigate(true);
      fUsage.selectInEditor();
    } else if (!usagesWereFound.get()) {
      String message =
          getNoUsagesFoundMessage(descriptor.getPrimaryElements()[0])
              + " in "
              + scopeFile.getName();
      showHintOrStatusBarMessage(message, fileEditor);
    } else {
      fileEditor.putUserData(KEY_START_USAGE_AGAIN, VALUE_START_USAGE_AGAIN);
      showHintOrStatusBarMessage(
          getSearchAgainMessage(descriptor.getPrimaryElements()[0], direction), fileEditor);
    }
  }
コード例 #2
0
 private void findUsages(
     @NotNull final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor,
     @NotNull final FindUsagesHandler handler,
     final boolean toSkipUsagePanelWhenOneUsage,
     final boolean toOpenInNewTab,
     @NotNull final FindUsagesOptions findUsagesOptions) {
   List<? extends PsiElement> elements = descriptor.getAllElements();
   if (elements.isEmpty()) {
     throw new AssertionError(handler + " " + findUsagesOptions);
   }
   final UsageTarget[] targets = convertToUsageTargets(elements);
   myAnotherManager.searchAndShowUsages(
       targets,
       new Factory<UsageSearcher>() {
         @Override
         public UsageSearcher create() {
           return createUsageSearcher(descriptor, handler, findUsagesOptions, null);
         }
       },
       !toSkipUsagePanelWhenOneUsage,
       true,
       createPresentation(elements.get(0), findUsagesOptions, toOpenInNewTab),
       null);
   addToHistory(elements, findUsagesOptions);
 }
コード例 #3
0
 private void initLastSearchElement(
     final FindUsagesOptions findUsagesOptions,
     UsageInfoToUsageConverter.TargetElementsDescriptor descriptor) {
   myLastSearchInFileData = createSearchData(descriptor.getAllElements(), findUsagesOptions);
 }