コード例 #1
0
  @Override
  public UsageView showUsages(
      UsageInfo[] usages,
      UsageViewPresentation presentation,
      UsageViewManager manager,
      PsiElement[] elements) {
    final List<PsiElement> overridingMethods = new ArrayList<>();
    final List<UsageInfo> others = new ArrayList<>();
    for (UsageInfo usage : usages) {
      if (usage instanceof SafeDeleteOverridingMethodUsageInfo) {
        overridingMethods.add(((SafeDeleteOverridingMethodUsageInfo) usage).getOverridingMethod());
      } else {
        others.add(usage);
      }
    }

    UsageTarget[] targets = new UsageTarget[elements.length + overridingMethods.size()];
    for (int i = 0; i < targets.length; i++) {
      if (i < elements.length) {
        targets[i] = new PsiElement2UsageTargetAdapter(elements[i]);
      } else {
        targets[i] = new PsiElement2UsageTargetAdapter(overridingMethods.get(i - elements.length));
      }
    }

    return manager.showUsages(
        targets,
        UsageInfoToUsageConverter.convert(elements, others.toArray(new UsageInfo[others.size()])),
        presentation);
  }
コード例 #2
0
  private UsageView showUsages(
      UsageInfo[] usages, UsageViewPresentation presentation, UsageViewManager manager) {
    for (SafeDeleteProcessorDelegate delegate :
        Extensions.getExtensions(SafeDeleteProcessorDelegate.EP_NAME)) {
      if (delegate instanceof SafeDeleteProcessorDelegateBase) {
        final UsageView view =
            ((SafeDeleteProcessorDelegateBase) delegate)
                .showUsages(usages, presentation, manager, myElements);
        if (view != null) return view;
      }
    }
    UsageTarget[] targets = new UsageTarget[myElements.length];
    for (int i = 0; i < targets.length; i++) {
      targets[i] = new PsiElement2UsageTargetAdapter(myElements[i]);
    }

    return manager.showUsages(
        targets, UsageInfoToUsageConverter.convert(myElements, usages), presentation);
  }
コード例 #3
0
  private void showUsageView(
      @NotNull final UsageViewDescriptor viewDescriptor,
      final Factory<UsageSearcher> factory,
      @NotNull final UsageInfo[] usageInfos) {
    UsageViewManager viewManager = UsageViewManager.getInstance(myProject);

    final PsiElement[] initialElements = viewDescriptor.getElements();
    final UsageTarget[] targets = PsiElement2UsageTargetAdapter.convert(initialElements);
    final Ref<Usage[]> convertUsagesRef = new Ref<>();
    if (!ProgressManager.getInstance()
        .runProcessWithProgressSynchronously(
            new Runnable() {
              @Override
              public void run() {
                ApplicationManager.getApplication()
                    .runReadAction(
                        new Runnable() {
                          @Override
                          public void run() {
                            convertUsagesRef.set(UsageInfo2UsageAdapter.convert(usageInfos));
                          }
                        });
              }
            },
            "Preprocess usages",
            true,
            myProject)) return;

    if (convertUsagesRef.isNull()) return;

    final Usage[] usages = convertUsagesRef.get();

    final UsageViewPresentation presentation = createPresentation(viewDescriptor, usages);

    final UsageView usageView = viewManager.showUsages(targets, usages, presentation, factory);
    customizeUsagesView(viewDescriptor, usageView);
  }