本文整理汇总了Java中com.intellij.usages.UsageDataUtil类的典型用法代码示例。如果您正苦于以下问题:Java UsageDataUtil类的具体用法?Java UsageDataUtil怎么用?Java UsageDataUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsageDataUtil类属于com.intellij.usages包,在下文中一共展示了UsageDataUtil类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getData
import com.intellij.usages.UsageDataUtil; //导入依赖的package包/类
@Override
public VirtualFile[] getData(@Nonnull final DataProvider dataProvider) {
// Try to detect multiselection.
Project project = dataProvider.getDataUnchecked(PlatformDataKeys.PROJECT_CONTEXT);
if (project != null && !project.isDisposed()) {
return ProjectRootManager.getInstance(project).getContentRoots();
}
Module[] selectedModules = dataProvider.getDataUnchecked(LangDataKeys.MODULE_CONTEXT_ARRAY);
if (selectedModules != null && selectedModules.length > 0) {
return getFilesFromModules(selectedModules);
}
Module selectedModule = dataProvider.getDataUnchecked(LangDataKeys.MODULE_CONTEXT);
if (selectedModule != null && !selectedModule.isDisposed()) {
return ModuleRootManager.getInstance(selectedModule).getContentRoots();
}
PsiElement[] psiElements = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT_ARRAY);
if (psiElements != null && psiElements.length != 0) {
return getFilesFromPsiElements(psiElements);
}
// VirtualFile -> VirtualFile[]
VirtualFile vFile = dataProvider.getDataUnchecked(PlatformDataKeys.VIRTUAL_FILE);
if (vFile != null) {
return new VirtualFile[]{vFile};
}
//
PsiFile psiFile = dataProvider.getDataUnchecked(LangDataKeys.PSI_FILE);
if (psiFile != null && psiFile.getVirtualFile() != null) {
return new VirtualFile[]{psiFile.getVirtualFile()};
}
PsiElement elem = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT);
if (elem != null) {
return getFilesFromPsiElement(elem);
}
Usage[] usages = dataProvider.getDataUnchecked(UsageView.USAGES_KEY);
UsageTarget[] usageTargets = dataProvider.getDataUnchecked(UsageView.USAGE_TARGETS_KEY);
if (usages != null || usageTargets != null) {
return UsageDataUtil.provideVirtualFileArray(usages, usageTargets);
}
return null;
}