本文整理汇总了Java中com.intellij.openapi.roots.ModuleRootManager.getContentRoots方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleRootManager.getContentRoots方法的具体用法?Java ModuleRootManager.getContentRoots怎么用?Java ModuleRootManager.getContentRoots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ModuleRootManager
的用法示例。
在下文中一共展示了ModuleRootManager.getContentRoots方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findRequirementsTxt
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Nullable
public static VirtualFile findRequirementsTxt(@NotNull Module module) {
final String requirementsPath = PyPackageRequirementsSettings.getInstance(module).getRequirementsPath();
if (!requirementsPath.isEmpty()) {
final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(requirementsPath);
if (file != null) {
return file;
}
final ModuleRootManager manager = ModuleRootManager.getInstance(module);
for (VirtualFile root : manager.getContentRoots()) {
final VirtualFile fileInRoot = root.findFileByRelativePath(requirementsPath);
if (fileInRoot != null) {
return fileInRoot;
}
}
}
return null;
}
示例2: doGenerate
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
private static <T> void doGenerate(@NotNull WebProjectTemplate<T> template, @NotNull Module module) {
WebProjectGenerator.GeneratorPeer<T> peer = template.getPeer();
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
VirtualFile[] contentRoots = moduleRootManager.getContentRoots();
VirtualFile dir = module.getProject().getBaseDir();
if (contentRoots.length > 0 && contentRoots[0] != null) {
dir = contentRoots[0];
}
template.generateProject(module.getProject(), dir, peer.getSettings(), module);
}
示例3: getChildren
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
Module module = getValue();
if (module == null || module.isDisposed()) { // module has been disposed
return Collections.emptyList();
}
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
ModuleFileIndex moduleFileIndex = rootManager.getFileIndex();
final VirtualFile[] contentRoots = rootManager.getContentRoots();
final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>(contentRoots.length + 1);
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
for (final VirtualFile contentRoot : contentRoots) {
if (!moduleFileIndex.isInContent(contentRoot)) continue;
if (contentRoot.isDirectory()) {
PsiDirectory directory = psiManager.findDirectory(contentRoot);
if (directory != null) {
children.add(new PsiDirectoryNode(getProject(), directory, getSettings()));
}
}
else {
PsiFile file = psiManager.findFile(contentRoot);
if (file != null) {
children.add(new PsiFileNode(getProject(), file, getSettings()));
}
}
}
/*
if (getSettings().isShowLibraryContents()) {
children.add(new LibraryGroupNode(getProject(), new LibraryGroupElement(getValue()), getSettings()));
}
*/
return children;
}
示例4: commitModule
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Nullable
@Override
public Module commitModule(@NotNull Project project, @Nullable ModifiableModuleModel model) {
Module module = super.commitModule(project, model);
if (module != null && myGenerator != null) {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
VirtualFile[] contentRoots = moduleRootManager.getContentRoots();
VirtualFile dir = module.getProject().getBaseDir();
if (contentRoots.length > 0 && contentRoots[0] != null) {
dir = contentRoots[0];
}
myGenerator.generateProject(project, dir, null, module);
}
return module;
}
示例5: getEditorTabTitle
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
public String getEditorTabTitle(Project project, VirtualFile file) {
if (GradleConstants.EXTENSION.equals(file.getExtension()) && GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName())) {
for (Module module : ModuleManager.getInstance(project).getModules()) {
if (module.isDisposed()) return null;
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
for (VirtualFile virtualFile : moduleRootManager.getContentRoots()) {
if (virtualFile.equals(file.getParent())) return module.getName();
}
}
}
return null;
}