本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}