speed up save — track inspection scheme state

This commit is contained in:
Vladimir Krivosheev
2016-12-15 16:31:30 +01:00
parent 31a31c8e42
commit 8dd7582c01
20 changed files with 127 additions and 142 deletions
@@ -84,7 +84,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
}
private static InspectionProfileImpl createProfile() {
return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileImpl.getBaseProfile());
return createProfile(InspectionProfileKt.getBASE_PROFILE());
}
private static InspectionProfileImpl createProfile(@NotNull InspectionProfileImpl base) {
@@ -100,8 +100,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
try {
//normally on open project profile wrappers are init for both managers
updateProfile(profileManager, localProfile);
InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager,
InspectionProfileImpl.getBaseProfile(), null);
InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager, null);
updateProfile(projectProfileManager, profile);
projectProfileManager.setRootProfile(profile.getName());
@@ -550,7 +549,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
}
private static InspectionProfileImpl createProfile(@NotNull InspectionToolRegistrar registrar) {
InspectionProfileImpl base = new InspectionProfileImpl("Base", registrar);
InspectionProfileImpl base = new InspectionProfileImpl("Base", registrar, (InspectionProfileImpl)null);
return new InspectionProfileImpl("Foo", registrar, base);
}
@@ -589,7 +588,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
}
public void testDoNotInstantiateOnSave() throws Exception {
InspectionProfileImpl profile = new InspectionProfileImpl("profile", InspectionToolRegistrar.getInstance(), InspectionProfileImpl.getBaseProfile());
InspectionProfileImpl profile = new InspectionProfileImpl("profile", InspectionToolRegistrar.getInstance(), InspectionProfileKt.getBASE_PROFILE());
assertEquals(0, countInitializedTools(profile));
InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null);
assertTrue(toolWrappers.length > 0);
@@ -17,8 +17,9 @@ package com.intellij.codeInspection.ex
import com.intellij.configurationStore.SchemeManagerFactoryBase
import com.intellij.openapi.application.ApplicationManager
import com.intellij.testFramework.rules.InMemoryFsRule
import com.intellij.openapi.options.SchemeState
import com.intellij.testFramework.ProjectRule
import com.intellij.testFramework.rules.InMemoryFsRule
import com.intellij.testFramework.runInInitMode
import com.intellij.util.io.readText
import com.intellij.util.io.write
@@ -53,12 +54,15 @@ class InspectionSchemeTest {
assertThat(profileManager.profiles).hasSize(1)
val scheme = profileManager.profiles.first()
assertThat(scheme.schemeState).isEqualTo(SchemeState.UNCHANGED)
assertThat(scheme.name).isEqualTo("Bar")
runInInitMode { scheme.initInspectionTools(null) }
schemeManagerFactory.save()
assertThat(scheme.schemeState).isEqualTo(SchemeState.UNCHANGED)
assertThat(schemeFile.readText()).isEqualTo(schemeData)
profileManager.profiles