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();
}
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();
}
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();
}
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);
});
}
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");
}
Aggregations