Search in sources :

Example 11 with ModifiableModuleModel

use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.

the class StructureConfigurableContext method getRealName.

public String getRealName(final Module module) {
    final ModifiableModuleModel moduleModel = myModulesConfigurator.getModuleModel();
    String newName = moduleModel.getNewName(module);
    return newName != null ? newName : module.getName();
}
Also used : ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel)

Example 12 with ModifiableModuleModel

use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.

the class DirectoryIndexTest method testModuleInIgnoredDir.

public void testModuleInIgnoredDir() {
    final VirtualFile ignored = createChildDirectory(myRootVFile, ".git");
    assertTrue(FileTypeManager.getInstance().isFileIgnored(ignored));
    new WriteCommandAction.Simple(getProject()) {

        @Override
        protected void run() throws Throwable {
            ModuleManager moduleManager = ModuleManager.getInstance(myProject);
            ModifiableModuleModel model = moduleManager.getModifiableModel();
            model.disposeModule(myModule);
            model.disposeModule(myModule2);
            model.disposeModule(myModule3);
            model.commit();
            Module module = moduleManager.newModule(myRootVFile.getPath() + "/newModule.iml", StdModuleTypes.JAVA.getId());
            PsiTestUtil.addContentRoot(module, ignored);
            checkInfo(ignored, module, false, false, null, null);
        }
    }.execute().throwException();
}
Also used : ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) ModuleManager(com.intellij.openapi.module.ModuleManager) Module(com.intellij.openapi.module.Module)

Example 13 with ModifiableModuleModel

use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.

the class MultiModuleEditingTest method testAddTwoModules.

public void testAddTwoModules() throws Exception {
    final MessageBusConnection connection = myProject.getMessageBus().connect();
    final MyModuleListener moduleListener = new MyModuleListener();
    connection.subscribe(ProjectTopics.MODULES, moduleListener);
    final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
    final Module moduleA;
    final Module moduleB;
    {
        final ModifiableModuleModel modifiableModel = moduleManager.getModifiableModel();
        moduleA = modifiableModel.newModule("a.iml", StdModuleTypes.JAVA.getId());
        moduleB = modifiableModel.newModule("b.iml", StdModuleTypes.JAVA.getId());
        assertEquals("Changes are not applied until commit", 0, moduleManager.getModules().length);
        //noinspection SSBasedInspection
        moduleListener.assertCorrectEvents(new String[0][]);
        ApplicationManager.getApplication().runWriteAction(modifiableModel::commit);
    }
    assertEquals(2, moduleManager.getModules().length);
    assertTrue(moduleManager.findModuleByName("a").equals(moduleA));
    assertTrue(moduleManager.findModuleByName("b").equals(moduleB));
    moduleListener.assertCorrectEvents(new String[][] { { "+a", "+b" } });
    {
        final ModifiableModuleModel modifiableModel = moduleManager.getModifiableModel();
        modifiableModel.disposeModule(moduleA);
        modifiableModel.disposeModule(moduleB);
        assertEquals("Changes are not applied until commit", 2, moduleManager.getModules().length);
        moduleListener.assertCorrectEvents(new String[][] { { "+a", "+b" } });
        ApplicationManager.getApplication().runWriteAction(modifiableModel::commit);
    }
    assertEquals(0, moduleManager.getModules().length);
    moduleListener.assertCorrectEvents(new String[][] { { "+a", "+b" }, { "-a", "-b" } });
    connection.disconnect();
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) ModuleManager(com.intellij.openapi.module.ModuleManager) Module(com.intellij.openapi.module.Module)

Example 14 with ModifiableModuleModel

use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.

the class ExportingModulesTest method test1.

public void test1() throws Exception {
    final String rootPath = PathManagerEx.getTestDataPath().replace(File.separatorChar, '/') + "/moduleRootManager/exportedModules/";
    final VirtualFile testRoot = LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath);
    assertNotNull(testRoot);
    ApplicationManager.getApplication().runWriteAction(() -> {
        final ModifiableModuleModel moduleModel = ModuleManager.getInstance(myProject).getModifiableModel();
        final Module moduleA = moduleModel.newModule("A.iml", StdModuleTypes.JAVA.getId());
        final Module moduleB = moduleModel.newModule("B.iml", StdModuleTypes.JAVA.getId());
        final Module moduleC = moduleModel.newModule("C.iml", StdModuleTypes.JAVA.getId());
        moduleModel.commit();
        configureModule(moduleA, testRoot, "A");
        configureModule(moduleB, testRoot, "B");
        configureModule(moduleC, testRoot, "C");
        ModuleRootModificationUtil.addDependency(moduleB, moduleA, DependencyScope.COMPILE, true);
        ModuleRootModificationUtil.addDependency(moduleC, moduleB);
        final PsiClass pCClass = JavaPsiFacade.getInstance(myProject).findClass("p.C", GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(moduleC));
        assertNotNull(pCClass);
        final PsiClass pAClass = JavaPsiFacade.getInstance(myProject).findClass("p.A", GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(moduleB));
        assertNotNull(pAClass);
        final PsiClass pAClass2 = JavaPsiFacade.getInstance(myProject).findClass("p.A", GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(moduleC));
        assertNotNull(pAClass2);
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) PsiClass(com.intellij.psi.PsiClass) Module(com.intellij.openapi.module.Module)

Example 15 with ModifiableModuleModel

use of com.intellij.openapi.module.ModifiableModuleModel in project intellij-community by JetBrains.

the class DependenciesPanelTest method testModuleGroups.

public void testModuleGroups() throws Exception {
    ModifiableModuleModel model = ModuleManager.getInstance(myProject).getModifiableModel();
    model.setModuleGroupPath(myModule, new String[] { "a", "b" });
    model.renameModule(myModule, "module");
    WriteAction.run(model::commit);
    // groups aren't shown for single-module projects so we need to add an empty second module
    createModule("util");
    DependencyUISettings settings = DependencyUISettings.getInstance();
    settings.UI_GROUP_BY_SCOPE_TYPE = false;
    settings.UI_SHOW_FILES = false;
    settings.SCOPE_TYPE = ProjectPatternProvider.FILE;
    doTestDependenciesTrees(new AnalysisScope(myModule), "-Root\n" + " -[a]\n" + "  -b\n" + "   -module\n" + "    -dependencies\n" + "     -src\n" + "      com/package1\n", "Root\n");
}
Also used : AnalysisScope(com.intellij.analysis.AnalysisScope) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) DependencyUISettings(com.intellij.packageDependencies.DependencyUISettings)

Aggregations

ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)44 Module (com.intellij.openapi.module.Module)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 ModuleManager (com.intellij.openapi.module.ModuleManager)10 Project (com.intellij.openapi.project.Project)9 NotNull (org.jetbrains.annotations.NotNull)8 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)5 File (java.io.File)5 Result (com.intellij.openapi.application.Result)4 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 StdModuleTypes (com.intellij.openapi.module.StdModuleTypes)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Task (com.intellij.openapi.progress.Task)3 ProjectLibraryTable (com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable)3 Nullable (org.jetbrains.annotations.Nullable)3 Project (aQute.bnd.build.Project)2 MoveModulesToSubGroupAction (com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction)2 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)2