diff --git a/build/order.txt b/build/order.txt index 75cfa9c4af0d..65bd2e4078e4 100644 --- a/build/order.txt +++ b/build/order.txt @@ -1345,7 +1345,6 @@ com/intellij/psi/filters/ElementFilter.class:/lib/openapi.jar com/intellij/profile/codeInspection/InspectionProfileManager.class:/lib/idea.jar com/intellij/profile/codeInspection/SeverityProvider.class:/lib/idea.jar com/intellij/profile/ApplicationProfileManager.class:/lib/openapi.jar -com/intellij/profile/ProfileManager.class:/lib/openapi.jar com/intellij/codeInspection/InspectionProfile.class:/lib/openapi.jar com/intellij/profile/Profile.class:/lib/openapi.jar com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.class:/lib/idea.jar diff --git a/platform/analysis-api/src/com/intellij/profile/ProfileManager.java b/platform/analysis-api/src/com/intellij/profile/ProfileManager.java deleted file mode 100644 index 0400937a9b3d..000000000000 --- a/platform/analysis-api/src/com/intellij/profile/ProfileManager.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2016 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.profile; - -import com.intellij.openapi.Disposable; -import org.jetbrains.annotations.NotNull; - -/** - * User: anna - * Date: 09-Dec-2005 - */ -public interface ProfileManager { - Profile getProfile(@NotNull String name, boolean returnRootProfileIfNamedIsAbsent); - - default Profile getProfile(@NotNull String name) { - return getProfile(name, true); - } - - @NotNull - String[] getAvailableProfileNames(); - - void addProfileChangeListener(@NotNull ProfileChangeAdapter listener, @NotNull Disposable parent); -} diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java index 5d9c768b903b..d854fb100a66 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java @@ -35,6 +35,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; +import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; import com.intellij.psi.*; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.scope.packageSet.NamedScope; @@ -112,20 +113,20 @@ public class GlobalInspectionContextBase extends UserDataHolderBase implements G } String currentProfile = ((InspectionManagerBase)InspectionManager.getInstance(myProject)).getCurrentProfile(); - final InspectionProjectProfileManager inspectionProfileManager = InspectionProjectProfileManager.getInstance(myProject); - InspectionProfileImpl profile = (InspectionProfileImpl)inspectionProfileManager.getProfile(currentProfile, false); + ProjectInspectionProfileManager profileManager = ProjectInspectionProfileManager.getInstanceImpl(myProject); + InspectionProfileImpl profile = profileManager.getProfile(currentProfile, false); if (profile == null) { profile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getProfile(currentProfile); if (profile != null) { return profile; } - final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames(); + final String[] availableProfileNames = profileManager.getAvailableProfileNames(); if (availableProfileNames.length == 0) { //can't be return null; } - profile = (InspectionProfileImpl)inspectionProfileManager.getProfile(availableProfileNames[0]); + profile = profileManager.getProfile(availableProfileNames[0], true); } return profile; } diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java index 6544f4d1fa82..1d63fc495c3a 100644 --- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/InspectionProfileManager.java @@ -16,17 +16,18 @@ package com.intellij.profile.codeInspection; import com.intellij.codeInspection.InspectionProfile; +import com.intellij.openapi.Disposable; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; import com.intellij.profile.Profile; -import com.intellij.profile.ProfileManager; +import com.intellij.profile.ProfileChangeAdapter; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; -public interface InspectionProfileManager extends ProfileManager, SeverityProvider { +public interface InspectionProfileManager extends SeverityProvider { String INSPECTION_DIR = "inspection"; @NotNull @@ -60,4 +61,12 @@ public interface InspectionProfileManager extends ProfileManager, SeverityProvid @NotNull InspectionProfile getCurrentProfile(); + + InspectionProfile getProfile(@NotNull String name, boolean returnRootProfileIfNamedIsAbsent); + + default InspectionProfile getProfile(@NotNull String name) { + return getProfile(name, true); + } + + void addProfileChangeListener(@NotNull ProfileChangeAdapter listener, @NotNull Disposable parent); } \ No newline at end of file diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt index 041ad0723b54..96fbe275d64b 100644 --- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt @@ -32,7 +32,6 @@ import com.intellij.openapi.startup.StartupActivity import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.text.StringUtil import com.intellij.packageDependencies.DependencyValidationManager -import com.intellij.profile.Profile import com.intellij.profile.ProfileEx import com.intellij.project.isDirectoryBased import com.intellij.psi.search.scope.packageSet.NamedScopeManager @@ -269,7 +268,7 @@ class ProjectInspectionProfileManager(val project: Project, return schemeManager.allSchemes } - @Synchronized override fun getAvailableProfileNames(): Array = schemeManager.allSchemeNames.toTypedArray() + @Synchronized fun getAvailableProfileNames(): Array = schemeManager.allSchemeNames.toTypedArray() val projectProfile: String? get() = schemeManager.currentSchemeName @@ -329,8 +328,8 @@ class ProjectInspectionProfileManager(val project: Project, } } - @Synchronized override fun getProfile(name: String, returnRootProfileIfNamedIsAbsent: Boolean): Profile? { + @Synchronized override fun getProfile(name: String, returnRootProfileIfNamedIsAbsent: Boolean): InspectionProfileImpl? { val profile = schemeManager.findSchemeByName(name) - return profile ?: applicationProfileManager.getProfile(name, returnRootProfileIfNamedIsAbsent) + return profile ?: applicationProfileManager.getProfile(name, returnRootProfileIfNamedIsAbsent) as InspectionProfileImpl? } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java index 98adf48e8951..6bb512792629 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/ApplicationInspectionProfileManager.java @@ -42,7 +42,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.ui.Messages; import com.intellij.profile.codeInspection.*; -import com.intellij.util.ArrayUtil; import com.intellij.util.ObjectUtils; import com.intellij.util.messages.MessageBus; import com.intellij.util.ui.UIUtil; @@ -274,12 +273,6 @@ public class ApplicationInspectionProfileManager extends BaseInspectionProfileMa return ObjectUtils.chooseNotNull(mySchemeManager.getCurrentSchemeName(), InspectionProfileImpl.DEFAULT_PROFILE_NAME); } - @Override - @NotNull - public String[] getAvailableProfileNames() { - return ArrayUtil.toStringArray(mySchemeManager.getAllSchemeNames()); - } - public static void onProfilesChanged() { //cleanup caches blindly for all projects in case ide profile was modified for (final Project project : ProjectManager.getInstance().getOpenProjects()) { diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index 0fcf0f0f86e3..5d9d795c5f79 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -44,11 +44,9 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.profile.ProfileManager; import com.intellij.profile.codeInspection.BaseInspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; -import com.intellij.profile.codeInspection.SeverityProvider; import com.intellij.profile.codeInspection.ui.filter.InspectionFilterAction; import com.intellij.profile.codeInspection.ui.filter.InspectionsFilter; import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode; @@ -270,8 +268,8 @@ public class SingleInspectionProfilePanel extends JPanel { return child; } - private static void copyUsedSeveritiesIfUndefined(InspectionProfileImpl selectedProfile, final ProfileManager profileManager) { - final SeverityRegistrar registrar = ((SeverityProvider)profileManager).getSeverityRegistrar(); + private static void copyUsedSeveritiesIfUndefined(InspectionProfileImpl selectedProfile, BaseInspectionProfileManager profileManager) { + final SeverityRegistrar registrar = profileManager.getSeverityRegistrar(); final Set severities = selectedProfile.getUsedSeverities(); for (Iterator iterator = severities.iterator(); iterator.hasNext();) { HighlightSeverity severity = iterator.next(); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java index 005a723ac46f..35f64489ceb3 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/header/InspectionToolsConfigurable.java @@ -47,7 +47,6 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.profile.Profile; -import com.intellij.profile.ProfileManager; import com.intellij.profile.codeInspection.BaseInspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.ProjectInspectionProfileManager; @@ -573,8 +572,6 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable } private boolean isDeleteEnabled(@NotNull InspectionProfileImpl inspectionProfile) { - final ProfileManager profileManager = inspectionProfile.getProfileManager(); - boolean projectProfileFound = false; boolean ideProfileFound = false; @@ -587,7 +584,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable if (ideProfileFound && projectProfileFound) break; } - return profileManager == myProjectProfileManager ? projectProfileFound : ideProfileFound; + return inspectionProfile.getProfileManager() == myProjectProfileManager ? projectProfileFound : ideProfileFound; } protected Collection getProfiles() {