use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class NonAndroidSourceTypeNode method getSourceFolders.
private List<VirtualFile> getSourceFolders() {
ModuleRootManager rootManager = ModuleRootManager.getInstance(getValue());
List<VirtualFile> folders = Lists.newArrayList();
ContentEntry[] contentEntries = rootManager.getContentEntries();
for (ContentEntry entry : contentEntries) {
List<SourceFolder> sources = entry.getSourceFolders(mySourceType.rootType);
for (SourceFolder folder : sources) {
VirtualFile file = folder.getFile();
if (file != null) {
folders.add(file);
}
}
}
return folders;
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class JavaModuleSetupTest method testSetUpAndroidModuleWithoutVariants.
public void testSetUpAndroidModuleWithoutVariants() {
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
when(myJavaModuleModel.isAndroidModuleWithoutVariants()).thenReturn(true);
Module module = getModule();
// Add AndroidFacet to verify that is removed.
createAndAddAndroidFacet(module);
ApplicationManager.getApplication().runWriteAction(() -> {
// Add source folders and excluded folders to verify that they are removed.
ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
ContentEntry contentEntry = modifiableModel.addContentEntry("file://fakePath");
contentEntry.addSourceFolder("file://fakePath/sourceFolder", false);
contentEntry.addExcludeFolder("file://fakePath/excludedFolder");
modifiableModel.commit();
});
myModuleSetup.setUpModule(module, modelsProvider, myJavaModuleModel, myModuleModels, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
// Verify AndroidFacet was removed.
assertNull(AndroidFacet.getInstance(module));
// Verify source folders and excluded folders were removed.
ContentEntry[] contentEntries = ModuleRootManager.getInstance(module).getContentEntries();
assertThat(contentEntries).hasLength(1);
ContentEntry contentEntry = contentEntries[0];
assertThat(contentEntry.getSourceFolders()).isEmpty();
assertThat(contentEntry.getExcludeFolderUrls()).isEmpty();
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class ContentRootsModuleSetupStepTest method addContentRoots.
private void addContentRoots(@NotNull String... names) throws IOException {
assertThat(names).isNotEmpty();
VirtualFile projectFolder = getProject().getBaseDir();
Module module = getModule();
ModuleRootManager manager = ModuleRootManager.getInstance(module);
ModifiableRootModel modifiableModel = manager.getModifiableModel();
for (String name : names) {
VirtualFile folder = findOrCreateChildFolder(projectFolder, name);
modifiableModel.addContentEntry(folder);
}
ApplicationManager.getApplication().runWriteAction(modifiableModel::commit);
ContentEntry[] entries = manager.getContentEntries();
assertThat(entries).hasLength(names.length);
}
use of com.intellij.openapi.roots.ContentEntry in project intellij-plugins by JetBrains.
the class DartHighlightingTest method unexcludeFolder.
private void unexcludeFolder(final String relPath) {
ApplicationManager.getApplication().runWriteAction(() -> {
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
try {
final ContentEntry[] contentEntries = model.getContentEntries();
contentEntries[0].removeExcludeFolder(contentEntries[0].getUrl() + "/" + relPath);
model.commit();
} finally {
if (!model.isDisposed()) {
model.dispose();
}
}
});
}
use of com.intellij.openapi.roots.ContentEntry in project intellij-plugins by JetBrains.
the class DartHighlightingTest method excludeFolder.
private void excludeFolder(final String relPath) {
ApplicationManager.getApplication().runWriteAction(() -> {
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
try {
final ContentEntry[] contentEntries = model.getContentEntries();
contentEntries[0].addExcludeFolder(contentEntries[0].getUrl() + "/" + relPath);
model.commit();
} finally {
if (!model.isDisposed()) {
model.dispose();
}
}
});
}
Aggregations