当前位置: 首页>>代码示例>>Java>>正文


Java UsageViewDescriptor.getElements方法代码示例

本文整理汇总了Java中com.intellij.usageView.UsageViewDescriptor.getElements方法的典型用法代码示例。如果您正苦于以下问题:Java UsageViewDescriptor.getElements方法的具体用法?Java UsageViewDescriptor.getElements怎么用?Java UsageViewDescriptor.getElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.usageView.UsageViewDescriptor的用法示例。


在下文中一共展示了UsageViewDescriptor.getElements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: previewRefactoring

import com.intellij.usageView.UsageViewDescriptor; //导入方法依赖的package包/类
protected void previewRefactoring(@NotNull UsageInfo[] usages) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    execute(usages);
    return;
  }
  final UsageViewDescriptor viewDescriptor = createUsageViewDescriptor(usages);
  final PsiElement[] elements = viewDescriptor.getElements();
  final PsiElement2UsageTargetAdapter[] targets = PsiElement2UsageTargetAdapter.convert(elements);
  Factory<UsageSearcher> factory = new Factory<UsageSearcher>() {
    @Override
    public UsageSearcher create() {
      return new UsageInfoSearcherAdapter() {
        @Override
        public void generate(@NotNull final Processor<Usage> processor) {
          ApplicationManager.getApplication().runReadAction(new Runnable() {
            @Override
            public void run() {
              for (int i = 0; i < elements.length; i++) {
                elements[i] = targets[i].getElement();
              }
              refreshElements(elements);
            }
          });
          processUsages(processor, myProject);
        }

        @Override
        protected UsageInfo[] findUsages() {
          return BaseRefactoringProcessor.this.findUsages();
        }
      };
    }
  };

  showUsageView(viewDescriptor, factory, usages);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:BaseRefactoringProcessor.java

示例2: showUsageView

import com.intellij.usageView.UsageViewDescriptor; //导入方法依赖的package包/类
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<Usage[]>();
  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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:BaseRefactoringProcessor.java

示例3: previewRefactoring

import com.intellij.usageView.UsageViewDescriptor; //导入方法依赖的package包/类
protected void previewRefactoring(@Nonnull UsageInfo[] usages) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    if (!PREVIEW_IN_TESTS) throw new RuntimeException("Unexpected preview in tests: " + StringUtil.join(usages, info -> info.toString(), ", "));
    ensureElementsWritable(usages, createUsageViewDescriptor(usages));
    execute(usages);
    return;
  }
  final UsageViewDescriptor viewDescriptor = createUsageViewDescriptor(usages);
  final PsiElement[] elements = viewDescriptor.getElements();
  final PsiElement2UsageTargetAdapter[] targets = PsiElement2UsageTargetAdapter.convert(elements);
  Factory<UsageSearcher> factory = new Factory<UsageSearcher>() {
    @Override
    public UsageSearcher create() {
      return new UsageInfoSearcherAdapter() {
        @Override
        public void generate(@Nonnull final Processor<Usage> processor) {
          ApplicationManager.getApplication().runReadAction(new Runnable() {
            @Override
            public void run() {
              for (int i = 0; i < elements.length; i++) {
                elements[i] = targets[i].getElement();
              }
              refreshElements(elements);
            }
          });
          processUsages(processor, myProject);
        }

        @Nonnull
        @Override
        protected UsageInfo[] findUsages() {
          return BaseRefactoringProcessor.this.findUsages();
        }
      };
    }
  };

  showUsageView(viewDescriptor, factory, usages);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:40,代码来源:BaseRefactoringProcessor.java

示例4: showUsageView

import com.intellij.usageView.UsageViewDescriptor; //导入方法依赖的package包/类
private void showUsageView(@Nonnull final UsageViewDescriptor viewDescriptor, final Factory<UsageSearcher> factory, @Nonnull 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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:BaseRefactoringProcessor.java

示例5: showUsageView

import com.intellij.usageView.UsageViewDescriptor; //导入方法依赖的package包/类
private void showUsageView(final UsageViewDescriptor viewDescriptor, final Factory<UsageSearcher> factory, 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<Usage[]>();
  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);

  final Runnable refactoringRunnable = new Runnable() {
    @Override
    public void run() {
      Set<UsageInfo> usagesToRefactor = getUsageInfosToRefactor(usageView);
      final UsageInfo[] infos = usagesToRefactor.toArray(new UsageInfo[usagesToRefactor.size()]);
      if (ensureElementsWritable(infos, viewDescriptor)) {
        execute(infos);
      }
    }
  };

  String canNotMakeString = RefactoringBundle.message("usageView.need.reRun");

  addDoRefactoringAction(usageView, refactoringRunnable, canNotMakeString);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:BaseRefactoringProcessor.java


注:本文中的com.intellij.usageView.UsageViewDescriptor.getElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。