use of com.intellij.openapi.roots.ModuleRootManager in project android by JetBrains.
the class IdeFrameFixture method getSourceFolderRelativePaths.
/**
* Returns a list of system independent paths
*/
@NotNull
public Collection<String> getSourceFolderRelativePaths(@NotNull String moduleName, @NotNull JpsModuleSourceRootType<?> sourceType) {
Set<String> paths = Sets.newHashSet();
Module module = getModule(moduleName);
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
try {
for (ContentEntry contentEntry : rootModel.getContentEntries()) {
for (SourceFolder folder : contentEntry.getSourceFolders()) {
JpsModuleSourceRootType<?> rootType = folder.getRootType();
if (rootType.equals(sourceType)) {
String path = urlToPath(folder.getUrl());
String relativePath = getRelativePath(myProjectPath, new File(toSystemDependentName(path)));
paths.add(PathUtil.toSystemIndependentName(relativePath));
}
}
}
} finally {
rootModel.dispose();
}
}
});
return paths;
}
use of com.intellij.openapi.roots.ModuleRootManager in project android by JetBrains.
the class NonAndroidModuleNode method getNonEmptySourceTypes.
private static Set<NonAndroidSourceType> getNonEmptySourceTypes(Module module) {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
Set<NonAndroidSourceType> sourceTypes = Sets.newHashSetWithExpectedSize(NonAndroidSourceType.values().length);
ContentEntry[] contentEntries = rootManager.getContentEntries();
for (ContentEntry entry : contentEntries) {
for (NonAndroidSourceType type : NonAndroidSourceType.values()) {
for (SourceFolder sourceFolder : entry.getSourceFolders(type.rootType)) {
if (sourceFolder.getFile() != null) {
sourceTypes.add(type);
break;
}
}
}
}
return sourceTypes;
}
use of com.intellij.openapi.roots.ModuleRootManager in project android by JetBrains.
the class ExcludedRoots method addFolderPathsFromExcludedModules.
private void addFolderPathsFromExcludedModules() {
for (Module module : myExcludedModules) {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
for (ContentEntry entry : rootManager.getContentEntries()) {
for (SourceFolder sourceFolder : entry.getSourceFolders()) {
myExcludedRoots.add(urlToFilePath(sourceFolder.getUrl()));
}
CompilerModuleExtension compiler = rootManager.getModuleExtension(CompilerModuleExtension.class);
String url = compiler.getCompilerOutputUrl();
if (isNotEmpty(url)) {
myExcludedRoots.add(urlToFilePath(url));
}
}
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(module);
if (androidModuleModel != null) {
myExcludedRoots.add(androidModuleModel.getMainArtifact().getJavaResourcesFolder());
}
}
}
use of com.intellij.openapi.roots.ModuleRootManager in project intellij-community by JetBrains.
the class CreateHtmlDescriptionFix method getPotentialRoots.
private static List<VirtualFile> getPotentialRoots(Module module, PsiDirectory[] dirs) {
if (dirs.length != 0) {
return StreamEx.of(dirs).map(PsiDirectory::getParentDirectory).nonNull().map(PsiDirectory::getVirtualFile).toList();
} else {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
List<VirtualFile> resourceRoots = rootManager.getSourceRoots(JavaResourceRootType.RESOURCE);
if (!resourceRoots.isEmpty()) {
return resourceRoots;
}
return rootManager.getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
}
}
use of com.intellij.openapi.roots.ModuleRootManager in project intellij-community by JetBrains.
the class PluginRunConfiguration method checkConfiguration.
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
if (getModule() == null) {
throw new RuntimeConfigurationException(DevKitBundle.message("run.configuration.no.module.specified"));
}
String moduleName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return getModule().getName();
}
});
if (ModuleManager.getInstance(getProject()).findModuleByName(moduleName) == null) {
throw new RuntimeConfigurationException(DevKitBundle.message("run.configuration.no.module.specified"));
}
final ModuleRootManager rootManager = ModuleRootManager.getInstance(getModule());
final Sdk sdk = rootManager.getSdk();
if (sdk == null) {
throw new RuntimeConfigurationException(DevKitBundle.message("sdk.no.specified", moduleName));
}
if (IdeaJdk.findIdeaJdk(sdk) == null) {
throw new RuntimeConfigurationException(DevKitBundle.message("sdk.type.incorrect", moduleName));
}
}
Aggregations