ModifiableModuleModel accepts module type ID as string; move it to projectModel-api

This commit is contained in:
Dmitry Jemerov
2012-05-17 13:04:31 +02:00
parent 507bc08020
commit 0acac64246
17 changed files with 99 additions and 39 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -280,7 +280,7 @@ public class ProjectFromSourcesBuilderImpl extends ProjectBuilder implements Pro
final String moduleFilePath = descriptor.computeModuleFilePath();
ModuleBuilder.deleteModuleFile(moduleFilePath);
final Module module = moduleModel.newModule(moduleFilePath, descriptor.getModuleType());
final Module module = moduleModel.newModule(moduleFilePath, descriptor.getModuleType().getId());
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
setupRootModel(projectDescriptor, descriptor, modifiableModel, projectLibs);
descriptor.updateModuleConfiguration(module, modifiableModel);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,7 +70,7 @@ public class ModulePointerTest extends PlatformTestCase {
final ModulePointer pointer = getPointerManager().create("xxx");
final ModifiableModuleModel modifiableModel = getModuleManager().getModifiableModel();
final Module module = modifiableModel.newModule(myProject.getBaseDir().getPath() + "/xxx.iml", EmptyModuleType.getInstance());
final Module module = modifiableModel.newModule(myProject.getBaseDir().getPath() + "/xxx.iml", EmptyModuleType.getInstance().getId());
assertSame(pointer, getPointerManager().create(module));
assertSame(pointer, getPointerManager().create("xxx"));
@@ -89,7 +89,7 @@ public class ModulePointerTest extends PlatformTestCase {
private Module addModule(final String name) {
final ModifiableModuleModel model = getModuleManager().getModifiableModel();
final Module module = model.newModule(myProject.getBaseDir().getPath() + "/" + name + ".iml", EmptyModuleType.getInstance());
final Module module = model.newModule(myProject.getBaseDir().getPath() + "/" + name + ".iml", EmptyModuleType.getInstance().getId());
commitModel(model);
disposeOnTearDown(new Disposable() {
@Override
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.resolve;
import com.intellij.openapi.application.ApplicationManager;
@@ -197,7 +212,7 @@ public class ResolveClassTest extends ResolveTestCase {
@Override
public void run() {
ModifiableModuleModel modifiableModel = ModuleManager.getInstance(getProject()).getModifiableModel();
Module module = modifiableModel.newModule("a.iml", StdModuleTypes.JAVA);
Module module = modifiableModel.newModule("a.iml", StdModuleTypes.JAVA.getId());
modifiableModel.commit();
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.psi.search;
import com.intellij.JavaTestUtil;
@@ -117,7 +132,7 @@ public class FindUsagesTest extends PsiTestCase{
@Override
protected void run(Result result) throws Throwable {
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
moduleModel.newModule("independent/independent.iml", StdModuleTypes.JAVA);
moduleModel.newModule("independent/independent.iml", StdModuleTypes.JAVA.getId());
moduleModel.commit();
tdf.createFile("plugin.xml", "<document>\n" +
@@ -1,6 +1,17 @@
/*
* Copyright (c) 2000-2004 by JetBrains s.r.o. All Rights Reserved.
* Use is subject to license terms.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.roots;
@@ -36,9 +47,9 @@ public class ExportingModulesTest extends IdeaTestCase {
@Override
public void run() {
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(myProject).getModifiableModel();
final Module moduleA = moduleModel.newModule("A.iml", StdModuleTypes.JAVA);
final Module moduleB = moduleModel.newModule("B.iml", StdModuleTypes.JAVA);
final Module moduleC = moduleModel.newModule("C.iml", StdModuleTypes.JAVA);
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");
@@ -68,8 +68,8 @@ public class MultiModuleEditingTest extends ModuleTestCase {
{
final ModifiableModuleModel modifiableModel = moduleManager.getModifiableModel();
moduleA = modifiableModel.newModule("a.iml", StdModuleTypes.JAVA);
moduleB = modifiableModel.newModule("b.iml", StdModuleTypes.JAVA);
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][]);
@@ -115,8 +115,8 @@ public class MultiModuleEditingTest extends ModuleTestCase {
final Module moduleB;
{
final ModifiableModuleModel moduleModel = moduleManager.getModifiableModel();
moduleA = moduleModel.newModule("a.iml", StdModuleTypes.JAVA);
moduleB = moduleModel.newModule("b.iml", StdModuleTypes.JAVA);
moduleA = moduleModel.newModule("a.iml", StdModuleTypes.JAVA.getId());
moduleB = moduleModel.newModule("b.iml", StdModuleTypes.JAVA.getId());
final ModifiableRootModel rootModelA = ModuleRootManager.getInstance(moduleA).getModifiableModel();
final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
rootModelB.addModuleOrderEntry(moduleA);
@@ -157,9 +157,9 @@ public class MultiModuleEditingTest extends ModuleTestCase {
{
final ModifiableModuleModel moduleModel = moduleManager.getModifiableModel();
moduleA = moduleModel.newModule("a.iml", StdModuleTypes.JAVA);
moduleB = moduleModel.newModule("b.iml", StdModuleTypes.JAVA);
final Module moduleC = moduleModel.newModule("c.iml", StdModuleTypes.JAVA);
moduleA = moduleModel.newModule("a.iml", StdModuleTypes.JAVA.getId());
moduleB = moduleModel.newModule("b.iml", StdModuleTypes.JAVA.getId());
final Module moduleC = moduleModel.newModule("c.iml", StdModuleTypes.JAVA.getId());
final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
rootModelB.addModuleOrderEntry(moduleC);
moduleModel.disposeModule(moduleC);