Search in sources :

Example 31 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.

the class ModuleDisposerTest method testDisposeModulesAndMarkImlFilesForDeletion.

public void testDisposeModulesAndMarkImlFilesForDeletion() {
    // This module should be disposed.
    Module libModule = createModule("lib");
    File libImlFilePath = new File(toSystemDependentName(libModule.getModuleFilePath()));
    Project project = getProject();
    IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
    myModuleDisposer.disposeModulesAndMarkImlFilesForDeletion(Collections.singletonList(libModule), project, modelsProvider);
    // Apply changes
    ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
    // Make sure module "lib" was disposed and its .iml file was deleted.
    assertTrue(Disposer.isDisposed(libModule));
    verify(myDisposedModules, times(1)).markImlFilesForDeletion(Collections.singletonList(libImlFilePath));
}
Also used : Project(com.intellij.openapi.project.Project) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) Module(com.intellij.openapi.module.Module) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) File(java.io.File)

Example 32 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.

the class ModuleDisposerTest method testDisposeModulesAndMarkImlFilesForDeletionWithNoModules.

public void testDisposeModulesAndMarkImlFilesForDeletionWithNoModules() {
    Project project = getProject();
    IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
    myModuleDisposer.disposeModulesAndMarkImlFilesForDeletion(Collections.emptyList(), project, modelsProvider);
    // Apply changes
    ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
    //noinspection unchecked
    verify(myDisposedModules, never()).markImlFilesForDeletion(anyList());
}
Also used : Project(com.intellij.openapi.project.Project) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)

Example 33 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.

the class FacetsTest method testRemoveAllFacetsWithAndroidGradleFacets.

public void testRemoveAllFacetsWithAndroidGradleFacets() throws Exception {
    createAndAddGradleFacet(myModule);
    FacetManager facetManager = FacetManager.getInstance(myModule);
    assertEquals(1, facetManager.getFacetsByType(GradleFacet.getFacetTypeId()).size());
    IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
    ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(myModule);
    Facets.removeAllFacets(facetModel, GradleFacet.getFacetTypeId());
    ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
    assertEquals(0, facetManager.getFacetsByType(GradleFacet.getFacetTypeId()).size());
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) FacetManager(com.intellij.facet.FacetManager)

Example 34 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.

the class GradleModuleSetupTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initMocks(this);
    Project project = getProject();
    IdeComponents.replaceService(project, GradleSyncState.class, mySyncState);
    String moduleName = "app";
    myModule = createModule(moduleName);
    IdeaProjectStub projectModel = new IdeaProjectStub(project.getName());
    myModuleModel = projectModel.addModule(moduleName, "task1", "task2");
    mySyncSummary = new GradleSyncSummary(project);
    when(mySyncState.getSummary()).thenReturn(mySyncSummary);
    myModelsProvider = new IdeModifiableModelsProviderImpl(project);
    myModuleSetup = new GradleModuleSetup();
}
Also used : Project(com.intellij.openapi.project.Project) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary) IdeaProjectStub(com.android.tools.idea.gradle.stubs.gradle.IdeaProjectStub)

Example 35 with IdeModifiableModelsProviderImpl

use of com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl in project android by JetBrains.

the class FacetsTest method testRemoveAllFacetsWithAndroidFacets.

public void testRemoveAllFacetsWithAndroidFacets() throws Exception {
    createAndAddAndroidFacet(myModule);
    FacetManager facetManager = FacetManager.getInstance(myModule);
    assertEquals(1, facetManager.getFacetsByType(AndroidFacet.ID).size());
    IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
    ModifiableFacetModel facetModel = modelsProvider.getModifiableFacetModel(myModule);
    Facets.removeAllFacets(facetModel, AndroidFacet.ID);
    ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
    assertEquals(0, facetManager.getFacetsByType(AndroidFacet.ID).size());
}
Also used : IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider) FacetManager(com.intellij.facet.FacetManager)

Aggregations

IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)36 IdeModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)18 Module (com.intellij.openapi.module.Module)16 Project (com.intellij.openapi.project.Project)9 File (java.io.File)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 DataNode (com.intellij.openapi.externalSystem.model.DataNode)4 Library (com.intellij.openapi.roots.libraries.Library)4 JavaModuleModel (com.android.tools.idea.gradle.project.model.JavaModuleModel)3 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)3 HashMap (java.util.HashMap)3 Set (java.util.Set)3 FacetManager (com.intellij.facet.FacetManager)2 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)2 IdeUIModifiableModelsProvider (com.intellij.openapi.externalSystem.service.project.IdeUIModifiableModelsProvider)2 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 ArrayList (java.util.ArrayList)2 MavenRootModelAdapter (org.jetbrains.idea.maven.importing.MavenRootModelAdapter)2 AndroidProject (com.android.builder.model.AndroidProject)1