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