use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class ContentRootsModuleSetupStepTest method testSetUpModule.
public void testSetUpModule() {
ModifiableRootModel moduleModel = myModelsProvider.getModifiableRootModel(getModule());
when(myFactory.create(myAndroidModel, moduleModel, false)).thenReturn(mySetup);
mySetupStep.setUpModule(getModule(), myModelsProvider, myAndroidModel, null, null);
ContentEntry[] entries = moduleModel.getContentEntries();
// Content roots "a", "b", and "c" should not be there, since they got removed.
assertThat(entries).hasLength(1);
assertEquals(myModuleFolder, entries[0].getFile());
ApplicationManager.getApplication().runWriteAction(myModelsProvider::commit);
verify(mySetup).execute(Arrays.asList(entries));
}
use of com.intellij.openapi.roots.ContentEntry 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.ContentEntry in project android by JetBrains.
the class ContentRootsModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull AndroidModuleModel androidModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
ModifiableRootModel moduleModel = ideModelsProvider.getModifiableRootModel(module);
boolean hasNativeModel = hasNativeModel(module, ideModelsProvider, gradleModels);
AndroidContentEntriesSetup setup = myContentEntriesSetupFactory.create(androidModel, moduleModel, hasNativeModel);
List<ContentEntry> contentEntries = findContentEntries(moduleModel, androidModel, hasNativeModel);
setup.execute(contentEntries);
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class ContentEntriesSetup method addOrphans.
protected void addOrphans() {
for (RootSourceFolder orphan : myOrphans) {
File path = orphan.getPath();
ContentEntry contentEntry = myModuleModel.addContentEntry(pathToIdeaUrl(path));
addSourceFolder(contentEntry, path, orphan.getType(), orphan.isGenerated());
}
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class ContentEntriesSetup method addSourceFolder.
protected void addSourceFolder(@NotNull File folderPath, @NotNull Collection<ContentEntry> contentEntries, @NotNull JpsModuleSourceRootType type, boolean generated) {
ContentEntry parent = findParentContentEntry(folderPath, contentEntries);
if (parent == null) {
myOrphans.add(new RootSourceFolder(folderPath, type, generated));
return;
}
addSourceFolder(parent, folderPath, type, generated);
}
Aggregations