remove ProfileManager

This commit is contained in:
Vladimir Krivosheev
2016-10-26 17:14:54 +02:00
parent 8cda01ca7a
commit c127252a08
8 changed files with 22 additions and 62 deletions
-1
View File
@@ -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
@@ -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);
}
@@ -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;
}
@@ -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);
}
@@ -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<String> = schemeManager.allSchemeNames.toTypedArray()
@Synchronized fun getAvailableProfileNames(): Array<String> = 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?
}
}
@@ -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()) {
@@ -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<HighlightSeverity> severities = selectedProfile.getUsedSeverities();
for (Iterator<HighlightSeverity> iterator = severities.iterator(); iterator.hasNext();) {
HighlightSeverity severity = iterator.next();
@@ -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<Profile> getProfiles() {