本文整理匯總了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;
}