diff --git a/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java b/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java index ba8ea7eeaa7b..9aae48874161 100644 --- a/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java +++ b/platform/lang-api/src/com/intellij/profile/DefaultProjectProfileManager.java @@ -15,6 +15,7 @@ */ package com.intellij.profile; +import com.intellij.openapi.Disposable; import com.intellij.openapi.components.StateSplitter; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -204,8 +205,14 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager return profile; } - public void addProfilesListener(ProfileChangeAdapter profilesListener) { + public void addProfilesListener(final ProfileChangeAdapter profilesListener, Disposable parent) { myProfilesListener.add(profilesListener); + Disposer.register(parent, new Disposable() { + @Override + public void dispose() { + myProfilesListener.remove(profilesListener); + } + }); } public void removeProfilesListener(ProfileChangeAdapter profilesListener) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java index bf7b2ba624b5..60d25f3665ed 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java @@ -63,6 +63,7 @@ import com.intellij.openapi.vfs.VirtualFilePropertyEvent; import com.intellij.profile.Profile; import com.intellij.profile.ProfileChangeAdapter; import com.intellij.profile.codeInspection.InspectionProfileManager; +import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.impl.PsiDocumentManagerImpl; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; @@ -229,8 +230,9 @@ class DaemonListeners implements Disposable { CommandProcessor.getInstance().addCommandListener(new MyCommandListener(), this); ApplicationListener applicationListener = new MyApplicationListener(); ApplicationManager.getApplication().addApplicationListener(applicationListener, this); - EditorColorsManager.getInstance().addEditorColorsListener(new MyEditorColorsListener(),this); + EditorColorsManager.getInstance().addEditorColorsListener(new MyEditorColorsListener(), this); InspectionProfileManager.getInstance().addProfileChangeListener(new MyProfileChangeListener(), this); + InspectionProjectProfileManager.getInstance(project).addProfilesListener(new MyProfileChangeListener(), this); TodoConfiguration.getInstance().addPropertyChangeListener(new MyTodoListener(), this); ActionManagerEx.getInstanceEx().addAnActionListener(new MyAnActionListener(), this); VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java index 7b4d26419477..2723b8940e36 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/WholeFileLocalInspectionsPassFactory.java @@ -80,11 +80,10 @@ public class WholeFileLocalInspectionsPassFactory extends AbstractProjectCompone myFileTools.clear(); } }; - myProfileManager.addProfilesListener(myProfilesListener); + myProfileManager.addProfilesListener(myProfilesListener, myProject); Disposer.register(myProject, new Disposable() { @Override public void dispose() { - myProfileManager.removeProfilesListener(myProfilesListener); myFileTools.clear(); } }); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java index 600ee089edc0..c29801d58402 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java @@ -356,7 +356,7 @@ public class InspectionProfileManager extends ApplicationProfileManager implemen return mySchemesManager; } - public void onProfilesChanged() { + public static void onProfilesChanged() { //cleanup caches blindly for all projects in case ide profile was modified for (Project project : ProjectManager.getInstance().getOpenProjects()) { HighlightingSettingsPerFile.getInstance(project).cleanProfileSettings(); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ProjectInspectionToolsConfigurable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ProjectInspectionToolsConfigurable.java index a37ffe08cf08..56d9e859ffed 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ProjectInspectionToolsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/ProjectInspectionToolsConfigurable.java @@ -53,6 +53,7 @@ public class ProjectInspectionToolsConfigurable extends InspectionToolsConfigura myProfileManager.setRootProfile(profileName); myProjectProfileManager.setProjectProfile(null); } + InspectionProfileManager.onProfilesChanged(); } @Override