inline ProjectRootManager.multiCommit() to direct ModuleRootManagerImpl.multiCommit() calls

This commit is contained in:
Dmitry Jemerov
2012-05-11 15:58:58 +02:00
parent 596c04e107
commit a837b84384
16 changed files with 112 additions and 84 deletions
@@ -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.roots;
import com.intellij.ProjectTopics;
@@ -12,8 +27,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -115,7 +129,7 @@ public class MultiModuleEditingTest extends ModuleTestCase {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ProjectRootManagerEx.getInstanceEx(myProject).multiCommit(moduleModel, new ModifiableRootModel[]{rootModelB, rootModelA});
ModuleRootManagerImpl.multiCommit(new ModifiableRootModel[]{rootModelB, rootModelA}, moduleModel);
}
});
}
@@ -152,7 +166,7 @@ public class MultiModuleEditingTest extends ModuleTestCase {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ProjectRootManager.getInstance(myProject).multiCommit(moduleModel, new ModifiableRootModel[]{rootModelB});
ModuleRootManagerImpl.multiCommit(new ModifiableRootModel[]{rootModelB}, moduleModel);
}
});
}
@@ -1,12 +1,29 @@
/*
* 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;
import com.intellij.ProjectTopics;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.impl.ModuleRootManagerImpl;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
@@ -74,7 +91,10 @@ public class RootsChangedTest extends ModuleTestCase {
final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
rootModelA.setSdk(jdk);
rootModelB.setSdk(jdk);
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
if (rootModels.length > 0) {
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
}
assertEventsCount(1);
final SdkModificator sdkModificator = jdk.getSdkModificator();
@@ -106,7 +126,10 @@ public class RootsChangedTest extends ModuleTestCase {
final ModifiableRootModel rootModelB = ModuleRootManager.getInstance(moduleB).getModifiableModel();
rootModelA.inheritSdk();
rootModelB.inheritSdk();
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
if (rootModels.length > 0) {
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
}
assertEventsCount(1);
ProjectRootManager.getInstance(myProject).setProjectSdk(jdk);
@@ -138,7 +161,10 @@ public class RootsChangedTest extends ModuleTestCase {
rootModelB.addLibraryEntry(libraryA);
rootModelA.addInvalidLibrary("Q", libraryTable.getTableLevel());
rootModelB.addInvalidLibrary("Q", libraryTable.getTableLevel());
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
if (rootModels.length > 0) {
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
}
assertEventsCount(1);
final Library.ModifiableModel libraryModifiableModel2 = libraryA.getModifiableModel();
@@ -195,7 +221,10 @@ public class RootsChangedTest extends ModuleTestCase {
final Library libraryQ = libraryTable.createLibrary("Q");
assertEventsCount(0);
ProjectRootManager.getInstance(myProject).multiCommit(new ModifiableRootModel[]{rootModelA, rootModelB});
ModifiableRootModel[] rootModels = new ModifiableRootModel[]{rootModelA, rootModelB};
if (rootModels.length > 0) {
ModuleRootManagerImpl.multiCommit(rootModels, ModuleManager.getInstance(rootModels[0].getProject()).getModifiableModel());
}
assertEventsCount(1);
libraryTable.removeLibrary(libraryQ);