model commit should only fire changes, but to not add scheme — it is pointless
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 11 Nov 2016 12:18:47 +0000 (13:18 +0100)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 11 Nov 2016 12:19:50 +0000 (13:19 +0100)
java/java-tests/testSrc/com/intellij/codeInspection/ex/InspectionProfileTest.java
platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileModifiableModel.kt
platform/analysis-impl/src/com/intellij/profile/codeInspection/BaseInspectionProfileManager.kt
platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java

index de9269ef60a288db1613be383268e9aef7149d9f..ba6bd28fd4341cbc4e2e49bde6b076cb64343507 100644 (file)
@@ -94,15 +94,15 @@ public class InspectionProfileTest extends LightIdeaTestCase {
   public void testSameNameSharedProfile() throws Exception {
     BaseInspectionProfileManager profileManager = getApplicationProfileManager();
     InspectionProfileImpl localProfile = createProfile();
-    profileManager.updateProfile(localProfile);
+    updateProfile(profileManager, localProfile);
 
     ProjectInspectionProfileManager projectProfileManager = ProjectInspectionProfileManager.getInstance(getProject());
     try {
       //normally on open project profile wrappers are init for both managers
-      profileManager.updateProfile(localProfile);
+      updateProfile(profileManager, localProfile);
       InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager,
                                                                 InspectionProfileImpl.getBaseProfile(), null);
-      projectProfileManager.updateProfile(profile);
+      updateProfile(projectProfileManager, profile);
       projectProfileManager.setRootProfile(profile.getName());
 
       assertTrue(projectProfileManager.getCurrentProfile() == profile);
@@ -112,6 +112,11 @@ public class InspectionProfileTest extends LightIdeaTestCase {
     }
   }
 
+  private static void updateProfile(BaseInspectionProfileManager profileManager, InspectionProfileImpl localProfile) {
+    profileManager.addProfile(localProfile);
+    profileManager.fireProfileChanged(localProfile);
+  }
+
   public void testConvertOldProfile() throws Exception {
     Element element = JDOMUtil.loadDocument("<inspections version=\"1.0\">\n" +
                                             "  <option name=\"myName\" value=\"ToConvert\" />\n" +
index f7720767a61eac3cfdc3f8be530d78f2068ab659..3b9cbb2f9daed95a18f46f165176ed9808103b18 100644 (file)
@@ -95,7 +95,6 @@ open class InspectionProfileModifiableModel(val source: InspectionProfileImpl) :
   //invoke when isChanged() == true
   fun commit() {
     source.commit(this)
-    profileManager.updateProfile(source)
     modified = false
   }
 
@@ -120,4 +119,5 @@ inline fun InspectionProfileImpl.edit(task: InspectionProfileModifiableModel.()
   val model = InspectionProfileModifiableModel(this)
   model.task()
   model.commit()
+  profileManager.fireProfileChanged(this)
 }
index 4a3f3453843df6898df930b32b76f531a70c51ed..a17c5301a8519658ab3fd4acea1684f631a99bc0 100644 (file)
@@ -24,7 +24,6 @@ import com.intellij.openapi.options.SchemeManager
 import com.intellij.openapi.options.SchemeState
 import com.intellij.openapi.project.Project
 import com.intellij.util.messages.MessageBus
-import org.jetbrains.annotations.TestOnly
 
 @JvmField
 internal val LOG = Logger.getInstance(BaseInspectionProfileManager::class.java)
@@ -44,7 +43,6 @@ abstract class BaseInspectionProfileManager(messageBus: MessageBus) :  Inspectio
     }
   }
 
-  @TestOnly
   fun addProfile(profile: InspectionProfileImpl) {
     schemeManager.addScheme(profile)
   }
@@ -64,11 +62,6 @@ abstract class BaseInspectionProfileManager(messageBus: MessageBus) :  Inspectio
   open protected fun schemeRemoved(scheme: InspectionProfile) {
   }
 
-  open fun updateProfile(profile: InspectionProfileImpl) {
-    schemeManager.addScheme(profile)
-    fireProfileChanged(profile)
-  }
-
   abstract fun fireProfileChanged(profile: InspectionProfileImpl)
 }
 
index dbd1e2b2cc2d2a265e17bf8c42dc8d6382edb055..0ddf1995966ae3841f6d2e8a386ecc87de7f7a4a 100644 (file)
@@ -1124,6 +1124,9 @@ public class SingleInspectionProfilePanel extends JPanel {
     }
 
     selectedProfile.commit();
+    profileManager.addProfile(source);
+    profileManager.fireProfileChanged(source);
+
     myModified = false;
     myRoot.dropCache();
     initToolStates();