use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class GradleSyncIntegrationTest method LoadPlainJavaProject.
// https://code.google.com/p/android/issues/detail?id=233038
public void LoadPlainJavaProject() throws Exception {
prepareProjectForImport(PURE_JAVA_PROJECT);
Project project = getProject();
importProject(project.getName(), getBaseDirPath(project), null);
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
ContentEntry[] entries = ModuleRootManager.getInstance(module).getContentEntries();
assertThat(entries).named(module.getName() + " should have content entries").isNotEmpty();
}
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class ContentRootsModuleSetupStepTest method indexByName.
@NotNull
private static Map<String, ContentEntry> indexByName(@NotNull ContentEntry[] contentEntries) {
Map<String, ContentEntry> entriesByName = new HashMap<>();
for (ContentEntry entry : contentEntries) {
VirtualFile file = entry.getFile();
assertNotNull(file);
entriesByName.put(file.getName(), entry);
}
return entriesByName;
}
use of com.intellij.openapi.roots.ContentEntry in project intellij-plugins by JetBrains.
the class AngularJSProjectConfigurator method configureProject.
@Override
public void configureProject(Project project, @NotNull VirtualFile baseDir, Ref<Module> moduleRef) {
final ModuleManager moduleManager = ModuleManager.getInstance(project);
final Module[] modules = moduleManager.getModules();
if (modules.length == 1) {
final VirtualFile cliJson = baseDir.findChild(ANGULAR_CLI_JSON);
final ModifiableRootModel model = ModuleRootManager.getInstance(modules[0]).getModifiableModel();
final ContentEntry entry = MarkRootActionBase.findContentEntry(model, baseDir);
if (entry != null && cliJson != null) {
excludeDefault(baseDir, entry);
ApplicationManager.getApplication().runWriteAction(() -> {
model.commit();
project.save();
});
} else {
model.dispose();
}
}
}
use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.
the class ContentRootsModuleSetupStepTest method testSetUpNativeModule.
public void testSetUpNativeModule() {
// Simulate this is a native module
NdkModuleModel ndkModuleModel = mock(NdkModuleModel.class);
when(ndkModuleModel.getSelectedVariant()).thenReturn(mock(NdkModuleModel.NdkVariant.class));
NdkFacet facet = addNativeAndroidFacet(myModelsProvider);
facet.setNdkModuleModel(ndkModuleModel);
ModifiableRootModel moduleModel = myModelsProvider.getModifiableRootModel(getModule());
when(myFactory.create(myAndroidModel, moduleModel, true)).thenReturn(mySetup);
mySetupStep.setUpModule(getModule(), myModelsProvider, myAndroidModel, null, null);
Map<String, ContentEntry> entriesByName = indexByName(moduleModel.getContentEntries());
// Content roots "a", "b", and "c" should be there, since they did not get removed because this is a native model.
assertThat(entriesByName).hasSize(4);
assertThat(entriesByName).containsKey("a");
assertThat(entriesByName).containsKey("b");
assertThat(entriesByName).containsKey("c");
ContentEntry newContentEntry = entriesByName.get(myModuleFolder.getName());
assertNotNull(newContentEntry);
ApplicationManager.getApplication().runWriteAction(myModelsProvider::commit);
verify(mySetup).execute(Collections.singletonList(newContentEntry));
}
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));
}
Aggregations