remove ApplicationProfileManager

This commit is contained in:
Vladimir Krivosheev
2016-06-07 12:36:49 +02:00
parent ff34b8cf19
commit 037be986b3
30 changed files with 98 additions and 289 deletions
@@ -31,7 +31,7 @@ import com.intellij.openapi.extensions.impl.ExtensionPointImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.psi.PsiDocCommentOwner;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
@@ -98,7 +98,7 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen
ADDITIONAL_ANNOS = null;
UIUtil.invokeLaterIfNeeded(() -> {
if (ApplicationManager.getApplication().isDisposed()) return;
ApplicationProfileManager.getInstance().fireProfileChanged(null);
InspectionProfileManager.getInstance().fireProfileChanged(null);
});
}
DaemonCodeAnalyzer.getInstance(project).restart(); // annotations changed
@@ -21,7 +21,7 @@ import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiElement;
@@ -67,7 +67,7 @@ public class SpecialAnnotationsUtilBase {
//correct save settings
//TODO lesya
ApplicationProfileManager.getInstance().fireProfileChanged(inspectionProfile);
InspectionProfileManager.getInstance().fireProfileChanged(inspectionProfile);
/*
try {
inspectionProfile.save();
@@ -11,7 +11,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.pom.Navigatable;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
import com.intellij.psi.javadoc.PsiDocComment;
@@ -398,7 +398,7 @@ public class JavaDocLocalInspection extends JavaDocLocalInspectionBase {
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
myInspection.registerAdditionalTag(myTag);
InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
ApplicationProfileManager.getInstance().fireProfileChanged(profile);
InspectionProfileManager.getInstance().fireProfileChanged(profile);
}
@Override
@@ -109,7 +109,7 @@ import com.intellij.openapi.util.Segment;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
import com.intellij.psi.impl.DebugUtil;
@@ -1199,7 +1199,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
public void testDaemonIgnoresFrameDeactivation() throws Throwable {
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true); // return default value to avoid unnecessary save
ApplicationProfileManager.getInstance().setRootProfile(InspectionProfileImpl.getDefaultProfile().getName()); // reset to default profile from the custom one to avoid unnecessary save
InspectionProfileManager.getInstance().setRootProfile(InspectionProfileImpl.getDefaultProfile().getName()); // reset to default profile from the custom one to avoid unnecessary save
String text = "class S { ArrayList<caret>XXX x;}";
configureByText(StdFileTypes.JAVA, text);
@@ -25,7 +25,6 @@ import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase;
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
@@ -82,10 +81,10 @@ public class InspectionProfileTest extends LightIdeaTestCase {
}
private static InspectionProfileImpl createProfile() {
return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), ApplicationProfileManager.getInstance(), InspectionProfileImpl.getDefaultProfile(), null);
return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), InspectionProfileImpl.getDefaultProfile(), null);
}
private static InspectionProfileImpl createProfile(@NotNull InspectionProfileImpl base) {
return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), ApplicationProfileManager.getInstance(), base, null);
return new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), base, null);
}
public void testSameNameSharedProfile() throws Exception {
@@ -100,7 +99,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
InspectionProfileImpl profile = new InspectionProfileImpl(PROFILE, InspectionToolRegistrar.getInstance(), projectProfileManager,
InspectionProfileImpl.getDefaultProfile(), null);
projectProfileManager.updateProfile(profile);
projectProfileManager.setProjectProfile(profile.getName());
projectProfileManager.setRootProfile(profile.getName());
assertTrue(projectProfileManager.getCurrentProfile() == profile);
}
@@ -27,7 +27,7 @@ package org.jetbrains.lang.manifest.highlighting;
import com.intellij.codeInspection.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
@@ -185,7 +185,7 @@ public class MisspelledHeaderInspection extends LocalInspectionTool {
myHeaders.add(myHeaderName);
InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
ApplicationProfileManager.getInstance().fireProfileChanged(profile);
InspectionProfileManager.getInstance().fireProfileChanged(profile);
}
}
}
@@ -24,7 +24,7 @@ import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.SeverityProvider;
import org.jdom.Document;
import org.jdom.Element;
@@ -130,7 +130,7 @@ public class InspectionProfileConvertor {
}
private static void renameOldDefaultsProfile() {
String directoryPath = PathManager.getConfigPath() + File.separator + ApplicationProfileManager.INSPECTION_DIR;
String directoryPath = PathManager.getConfigPath() + File.separator + InspectionProfileManager.INSPECTION_DIR;
File profileDirectory = new File(directoryPath);
if (!profileDirectory.exists()) {
return;
@@ -27,7 +27,7 @@ import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiElement;
import org.jdom.Element;
@@ -341,7 +341,7 @@ public interface HighlightInfoType {
@NotNull
public HighlightSeverity getSeverity(final PsiElement psiElement) {
InspectionProfile profile = psiElement == null
? ApplicationProfileManager.getInstance().getCurrentProfile()
? InspectionProfileManager.getInstance().getCurrentProfile()
: InspectionProjectProfileManager.getInstance(psiElement.getProject()).getCurrentProfile();
HighlightDisplayLevel level = profile.getErrorLevel(myToolKey, psiElement);
LOG.assertTrue(level != HighlightDisplayLevel.DO_NOT_SHOW);
@@ -23,8 +23,7 @@ import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.concurrency.AtomicFieldUpdater;
import com.intellij.util.containers.ContainerUtil;
@@ -82,8 +81,8 @@ public class SeverityRegistrar implements Comparator<HighlightSeverity> {
@NotNull
public static SeverityRegistrar getSeverityRegistrar(@Nullable Project project) {
return project == null
? ApplicationProfileManager.getInstance().getSeverityRegistrar()
: InspectionProjectProfileManager.getInstance(project).getSeverityRegistrar();
? InspectionProfileManager.getInstance().getSeverityRegistrar()
: InspectionProfileManager.getInstance(project).getSeverityRegistrar();
}
public void registerSeverity(@NotNull SeverityBasedTextAttributes info, Color renderColor) {
@@ -17,7 +17,7 @@ package com.intellij.codeInspection;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImpl;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NonNls;
@@ -177,7 +177,7 @@ public abstract class InspectionManagerBase extends InspectionManager {
if (myCurrentProfileName == null) {
myCurrentProfileName = ProjectInspectionProfileManagerImpl.getInstanceImpl(getProject()).getProjectProfile();
if (myCurrentProfileName == null) {
myCurrentProfileName = ApplicationProfileManager.getInstance().getCurrentProfile().getName();
myCurrentProfileName = InspectionProfileManager.getInstance().getCurrentProfile().getName();
}
}
return myCurrentProfileName;
@@ -33,8 +33,8 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
import com.intellij.psi.search.LocalSearchScope;
@@ -113,7 +113,7 @@ public class GlobalInspectionContextBase extends UserDataHolderBase implements G
final InspectionProjectProfileManager inspectionProfileManager = InspectionProjectProfileManager.getInstance(myProject);
Profile profile = inspectionProfileManager.getProfile(currentProfile, false);
if (profile == null) {
profile = ApplicationProfileManager.getInstance().getProfile(currentProfile);
profile = InspectionProfileManager.getInstance().getProfile(currentProfile);
if (profile != null) return (InspectionProfile)profile;
final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames();
@@ -32,9 +32,9 @@ import com.intellij.openapi.options.ExternalizableScheme;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.*;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.ProfileEx;
import com.intellij.profile.ProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImplKt;
import com.intellij.profile.codeInspection.SeverityProvider;
import com.intellij.psi.PsiElement;
@@ -110,7 +110,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
}
public InspectionProfileImpl(@NotNull @NonNls String profileName) {
this(profileName, InspectionToolRegistrar.getInstance(), ApplicationProfileManager.getInstance(), null, null);
this(profileName, InspectionToolRegistrar.getInstance(), InspectionProfileManager.getInstance(), null, null);
}
public InspectionProfileImpl(@NotNull String profileName,
@@ -148,7 +148,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
return Arrays.asList(toolWrappers);
}
};
final InspectionProfileImpl profile = new InspectionProfileImpl(name, registrar, ApplicationProfileManager.getInstance());
final InspectionProfileImpl profile = new InspectionProfileImpl(name, registrar, InspectionProfileManager.getInstance());
initAndDo((Computable)() -> {
profile.initInspectionTools(project);
return null;
@@ -455,7 +455,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
@Override
public void save() {
ApplicationProfileManager.getInstance().fireProfileChanged(this);
InspectionProfileManager.getInstance().fireProfileChanged(this);
}
@Nullable
@@ -480,7 +480,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
for (ScopeToolState toolState : getAllTools(null)) {
toolState.scopesChanged();
}
ApplicationProfileManager.getInstance().fireProfileChanged(this);
InspectionProfileManager.getInstance().fireProfileChanged(this);
}
@Override
@@ -818,7 +818,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
myTools = model.myTools;
myProfileManager = model.getProfileManager();
ApplicationProfileManager.getInstance().fireProfileChanged(model);
InspectionProfileManager.getInstance().fireProfileChanged(model);
}
@Tag
@@ -1,58 +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.components.ServiceManager;
import com.intellij.profile.codeInspection.SeverityProvider;
import com.intellij.psi.search.scope.packageSet.NamedScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface ApplicationProfileManager extends ProfileManager, SeverityProvider {
String INSPECTION_DIR = "inspection";
@NotNull
static ApplicationProfileManager getInstance() {
return ServiceManager.getService(ApplicationProfileManager.class);
}
@Deprecated
@SuppressWarnings("unused")
Profile createProfile();
@Deprecated
@SuppressWarnings("unused")
void addProfileChangeListener(@NotNull ProfileChangeAdapter listener);
@Deprecated
@SuppressWarnings("unused")
void removeProfileChangeListener(@NotNull ProfileChangeAdapter listener);
void fireProfileChanged(Profile profile);
void fireProfileChanged(Profile oldProfile, Profile profile, @Nullable NamedScope scope);
void setRootProfile(@Nullable String profileName);
@SuppressWarnings("unused")
@NotNull
@Deprecated
default Profile getRootProfile() {
return getCurrentProfile();
}
void addProfile(@NotNull Profile profile);
}
@@ -15,10 +15,46 @@
*/
package com.intellij.profile.codeInspection;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.profile.Profile;
import com.intellij.profile.ProfileChangeAdapter;
import com.intellij.profile.ProfileManager;
import com.intellij.psi.search.scope.packageSet.NamedScope;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface InspectionProfileManager extends ApplicationProfileManager {
public interface InspectionProfileManager extends ProfileManager, SeverityProvider {
String INSPECTION_DIR = "inspection";
@NotNull
static InspectionProfileManager getInstance() {
return (InspectionProfileManager)ApplicationProfileManager.getInstance();
return ServiceManager.getService(InspectionProfileManager.class);
}
@NotNull
static InspectionProfileManager getInstance(@NotNull Project project) {
return InspectionProjectProfileManager.getInstance(project);
}
@Deprecated
@SuppressWarnings("unused")
void addProfileChangeListener(@NotNull ProfileChangeAdapter listener);
@Deprecated
@SuppressWarnings("unused")
void removeProfileChangeListener(@NotNull ProfileChangeAdapter listener);
void fireProfileChanged(@NotNull Profile profile);
void fireProfileChanged(@NotNull Profile oldProfile, Profile profile, @Nullable NamedScope scope);
void setRootProfile(@Nullable String profileName);
@SuppressWarnings("unused")
@NotNull
@Deprecated
default Profile getRootProfile() {
return getCurrentProfile();
}
}
@@ -17,7 +17,6 @@ package com.intellij.profile.codeInspection;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.openapi.project.Project;
import com.intellij.profile.ProfileManager;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
@@ -25,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
* User: anna
* Date: 30-Nov-2005
*/
public interface InspectionProjectProfileManager extends ProfileManager, SeverityProvider {
public interface InspectionProjectProfileManager extends InspectionProfileManager {
static InspectionProjectProfileManager getInstance(@NotNull Project project){
return project.getComponent(InspectionProjectProfileManager.class);
}
@@ -282,7 +282,7 @@ class ProjectInspectionProfileManagerImpl(val project: Project,
val projectProfile: String?
get() = state.projectProfile
@Synchronized fun setProjectProfile(newProfile: String?) {
@Synchronized override fun setRootProfile(newProfile: String?) {
if (newProfile == state.projectProfile) {
return
}
@@ -29,9 +29,9 @@ import com.intellij.icons.AllIcons;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.options.ex.SingleConfigurableEditor;
import com.intellij.openapi.project.Project;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.ProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImpl;
import com.intellij.profile.codeInspection.ui.ErrorsConfigurable;
@@ -114,7 +114,7 @@ public class CodeInspectionAction extends BaseAnalysisAction {
}
}
});
final ApplicationProfileManager profileManager = ApplicationProfileManager.getInstance();
final InspectionProfileManager profileManager = InspectionProfileManager.getInstance();
final ProjectInspectionProfileManagerImpl projectProfileManager = ProjectInspectionProfileManagerImpl.getInstanceImpl(project);
reloadProfiles(profiles, profileManager, projectProfileManager, manager);
panel.myBrowseProfilesCombo.addActionListener(new ActionListener() {
@@ -186,7 +186,7 @@ public class CodeInspectionAction extends BaseAnalysisAction {
private void reloadProfiles(JComboBox profiles,
ApplicationProfileManager inspectionProfileManager,
InspectionProfileManager inspectionProfileManager,
InspectionProjectProfileManager inspectionProjectProfileManager,
InspectionManagerEx inspectionManager) {
final InspectionProfile selectedProfile = getGlobalInspectionContext(inspectionManager.getProject()).getCurrentProfile();
@@ -38,7 +38,6 @@ import com.intellij.openapi.options.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.*;
import com.intellij.util.ArrayUtil;
@@ -67,7 +66,7 @@ import static com.intellij.codeInspection.ex.InspectionProfileImpl.getDefaultPro
@Storage("editor.xml"),
@Storage(value = "other.xml", deprecated = true)
},
additionalExportFile = ApplicationProfileManager.INSPECTION_DIR
additionalExportFile = InspectionProfileManager.INSPECTION_DIR
)
public class ApplicationInspectionProfileManagerImpl extends BaseInspectionProfileManager implements InspectionProfileManager,
SeverityProvider,
@@ -233,7 +232,6 @@ public class ApplicationInspectionProfileManagerImpl extends BaseInspectionProfi
return new InspectionProfileConvertor(this);
}
@Override
public InspectionProfileImpl createProfile() {
return createSampleProfile(InspectionProfileImpl.DEFAULT_PROFILE_NAME, getDefaultProfile());
}
@@ -278,7 +276,6 @@ public class ApplicationInspectionProfileManagerImpl extends BaseInspectionProfi
}
}
@Override
public void addProfile(@NotNull Profile profile) {
mySchemeManager.addScheme((InspectionProfile)profile);
}
@@ -44,7 +44,7 @@ public class QuickChangeInspectionProfileAction extends QuickSwitchSchemeAction
group.add(new DumbAwareAction(scheme.getName(), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) {
@Override
public void actionPerformed(@Nullable AnActionEvent e) {
projectProfileManager.setProjectProfile(scheme.getName());
projectProfileManager.setRootProfile(scheme.getName());
}
});
}
@@ -28,6 +28,6 @@ import org.jetbrains.annotations.NotNull;
public class PlatformInspectionProfileConfigurator implements DirectoryProjectConfigurator {
@Override
public void configureProject(Project project, @NotNull VirtualFile baseDir, Ref<Module> moduleRef) {
ProjectInspectionProfileManagerImpl.getInstanceImpl(project).setProjectProfile(null);
ProjectInspectionProfileManagerImpl.getInstanceImpl(project).setRootProfile(null);
}
}
@@ -1,161 +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.codeInspection.ui;
import com.intellij.codeInspection.InspectionsBundle;
import com.intellij.codeInspection.ModifiableModel;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.ProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Set;
/**
* User: anna
* Date: 30-May-2006
*/
public class ProfilesComboBox extends JComboBox {
public static final String USE_GLOBAL_PROFILE = InspectionsBundle.message("profile.project.settings.disable.text");
private boolean myFrozenProfilesCombo;
private Condition<ModifiableModel> myUpdateCallback;
public void setUpdateCallback(final Condition<ModifiableModel> updateCallback) {
myUpdateCallback = updateCallback;
}
public void createProfilesCombo(final Profile selectedProfile, final Set<Profile> availableProfiles, final ProfileManager profileManager) {
reloadProfiles(profileManager, availableProfiles, selectedProfile);
setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final Component rendererComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Profile) {
final Profile profile = (Profile)value;
setText(profile.getName());
setIcon(profile.isProjectLevel() ? AllIcons.General.ProjectSettings : AllIcons.General.Settings);
}
else if (value instanceof String) {
setText((String)value);
}
return rendererComponent;
}
});
addItemListener(new ItemListener() {
private Object myDeselectedItem = null;
@Override
public void itemStateChanged(@NotNull ItemEvent e) {
if (myFrozenProfilesCombo) {
// do not update during reloading
return;
}
else if (ItemEvent.SELECTED == e.getStateChange()) {
final Object item = e.getItem();
if (profileManager instanceof InspectionProjectProfileManager && item instanceof Profile && !((Profile)item).isProjectLevel()) {
if (Messages.showOkCancelDialog(InspectionsBundle.message("inspection.new.profile.ide.to.project.warning.message"),
InspectionsBundle.message("inspection.new.profile.ide.to.project.warning.title"),
Messages.getErrorIcon()) == Messages.OK) {
final String newName = Messages.showInputDialog(InspectionsBundle.message("inspection.new.profile.text"),
InspectionsBundle.message("inspection.new.profile.dialog.title"),
Messages.getInformationIcon());
final Object selectedItem = getSelectedItem();
if (!StringUtil.isEmpty(newName) && selectedItem instanceof Profile) {
if (ArrayUtil.find(profileManager.getAvailableProfileNames(), newName) == -1 &&
ArrayUtil.find(InspectionProfileManager.getInstance().getAvailableProfileNames(), newName) == -1) {
saveNewProjectProfile(newName, (Profile)selectedItem, profileManager);
return;
}
else {
Messages.showErrorDialog(InspectionsBundle.message("inspection.unable.to.create.profile.message", newName),
InspectionsBundle.message("inspection.unable.to.create.profile.dialog.title"));
}
}
}
setSelectedItem(myDeselectedItem);
}
}
else {
myDeselectedItem = e.getItem();
}
}
});
}
private void saveNewProjectProfile(final String newName, final Profile profile, ProfileManager profileManager) {
InspectionProfileImpl inspectionProfile = new InspectionProfileImpl(newName, InspectionToolRegistrar.getInstance(), profileManager);
final ModifiableModel profileModifiableModel = inspectionProfile.getModifiableModel();
profileModifiableModel.copyFrom(profile);
profileModifiableModel.setProjectLevel(true);
profileModifiableModel.setName(newName);
((DefaultComboBoxModel)getModel()).addElement(profileModifiableModel);
setSelectedItem(profileModifiableModel);
if (myUpdateCallback != null){
myUpdateCallback.value(profileModifiableModel);
}
}
public void reloadProfiles(final ProfileManager profileManager, final Set<Profile> availableProfiles, final Profile selectedProfile) {
reloadProfiles(profileManager, true, availableProfiles, selectedProfile);
}
public void reloadProfiles(final ProfileManager profileManager, final boolean noneItemAppearance, final Set<Profile> availableProfiles, final Profile selectedProfile) {
myFrozenProfilesCombo = true;
Object oldSelection = getSelectedItem();
final DefaultComboBoxModel model = (DefaultComboBoxModel)getModel();
model.removeAllElements();
if (noneItemAppearance && profileManager instanceof InspectionProjectProfileManager) {
model.addElement(USE_GLOBAL_PROFILE);
}
for (Profile profile : availableProfiles) {
model.addElement(profile);
}
if (selectedProfile != null && ((!selectedProfile.isProjectLevel() && profileManager instanceof ApplicationProfileManager) ||
(selectedProfile.isProjectLevel() && profileManager instanceof InspectionProjectProfileManager))) {
setSelectedItem(selectedProfile);
}
else {
final int index = model.getIndexOf(oldSelection);
if (index != -1) {
setSelectedIndex(index);
}
else if (model.getSize() > 0) {
setSelectedIndex(0);
}
}
myFrozenProfilesCombo = false;
}
}
@@ -39,11 +39,11 @@ public class ProjectInspectionToolsConfigurable extends InspectionToolsConfigura
@Override
protected void applyRootProfile(@NotNull String name, boolean isProjectLevel) {
if (isProjectLevel) {
myProjectProfileManager.setProjectProfile(name);
myProjectProfileManager.setRootProfile(name);
}
else {
myApplicationProfileManager.setRootProfile(name);
myProjectProfileManager.setProjectProfile(null);
myProjectProfileManager.setRootProfile(null);
}
ApplicationInspectionProfileManagerImpl.onProfilesChanged();
}
@@ -45,7 +45,6 @@ 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.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.ProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
@@ -150,11 +149,11 @@ public class SingleInspectionProfilePanel extends JPanel {
}
private static VisibleTreeState getExpandedNodes(InspectionProfileImpl profile) {
if (profile.getProfileManager() instanceof ApplicationProfileManager) {
return AppInspectionProfilesVisibleTreeState.getInstance().getVisibleTreeState(profile);
if (profile.isProjectLevel()) {
return ProjectInspectionProfilesVisibleTreeState.getInstance(((ProjectInspectionProfileManagerImpl)profile.getProfileManager()).getProject()).getVisibleTreeState(profile);
}
else {
return ProjectInspectionProfilesVisibleTreeState.getInstance(((ProjectInspectionProfileManagerImpl)profile.getProfileManager()).getProject()).getVisibleTreeState(profile);
return AppInspectionProfilesVisibleTreeState.getInstance().getVisibleTreeState(profile);
}
}
@@ -46,9 +46,9 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.ProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImpl;
import com.intellij.profile.codeInspection.ui.ErrorsConfigurable;
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
@@ -79,7 +79,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
private static final Logger LOG = Logger.getInstance(InspectionToolsConfigurable.class);
private static final String COPY_SUFFIX = "copy";
protected final ApplicationProfileManager myApplicationProfileManager;
protected final InspectionProfileManager myApplicationProfileManager;
protected final ProjectInspectionProfileManagerImpl myProjectProfileManager;
private final CardLayout myLayout = new CardLayout();
private final Map<Profile, SingleInspectionProfilePanel> myPanels =
@@ -92,7 +92,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
public InspectionToolsConfigurable(@NotNull ProjectInspectionProfileManagerImpl projectProfileManager) {
myProjectProfileManager = projectProfileManager;
myApplicationProfileManager = ApplicationProfileManager.getInstance();
myApplicationProfileManager = InspectionProfileManager.getInstance();
}
private static JComponent withBorderOnTop(final JComponent component) {
@@ -441,7 +441,7 @@ public abstract class InspectionToolsConfigurable extends BaseConfigurable
}
public static InspectionProfileImpl importInspectionProfile(@NotNull Element rootElement,
@NotNull ApplicationProfileManager profileManager,
@NotNull InspectionProfileManager profileManager,
@NotNull Project project,
@Nullable JPanel anchorPanel)
throws JDOMException, IOException, InvalidDataException {
@@ -77,7 +77,7 @@ import com.intellij.openapi.vfs.impl.VirtualFilePointerManagerImpl;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFS;
import com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl;
import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
@@ -453,7 +453,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
lookupManager.hideActiveLookup();
}
((StartupManagerImpl)StartupManager.getInstance(project)).prepareForNextTest();
ApplicationProfileManager.getInstance().deleteProfile(PROFILE);
InspectionProfileManager.getInstance().deleteProfile(PROFILE);
if (ProjectManager.getInstance() == null) {
exceptions.add(new AssertionError("Application components damaged"));
}
@@ -84,7 +84,6 @@ import com.intellij.openapi.util.*;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.Profile;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.profile.codeInspection.ProjectInspectionProfileManagerImpl;
@@ -202,7 +201,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
final InspectionProfileImpl profile = InspectionProfileImpl.createSimple(LightPlatformTestCase.PROFILE, project, wrapped);
profile.disableToolByDefault(new ArrayList<String>(disabledInspections), project);
final ApplicationProfileManager inspectionProfileManager = ApplicationProfileManager.getInstance();
final ApplicationInspectionProfileManagerImpl inspectionProfileManager = ApplicationInspectionProfileManagerImpl.getInstanceImpl();
final Profile oldRootProfile = inspectionProfileManager.getCurrentProfile();
inspectionProfileManager.addProfile(profile);
Disposer.register(parentDisposable, new Disposable() {
@@ -216,7 +215,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
inspectionProfileManager.setRootProfile(profile.getName());
InspectionProfileImpl.initAndDo((Computable)() -> {
InspectionProjectProfileManager.getInstance(project).updateProfile(profile);
ProjectInspectionProfileManagerImpl.getInstanceImpl(project).setProjectProfile(profile.getName());
ProjectInspectionProfileManagerImpl.getInstanceImpl(project).setRootProfile(profile.getName());
return null;
});
}
@@ -19,7 +19,7 @@ import com.intellij.codeInspection.*;
import com.intellij.codeInspection.ui.ListEditForm;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiComment;
@@ -109,7 +109,7 @@ public class SuppressionAnnotationInspection extends SuppressionAnnotationInspec
private void saveProfile(Project project) {
final InspectionProfile inspectionProfile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
ApplicationProfileManager.getInstance().fireProfileChanged(inspectionProfile);
InspectionProfileManager.getInstance().fireProfileChanged(inspectionProfile);
}
@NotNull
@@ -21,7 +21,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.LabeledComponent;
import com.intellij.openapi.util.JDOMExternalizableStringList;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.*;
import com.intellij.ui.DocumentAdapter;
@@ -165,7 +165,7 @@ public class DependsOnGroupsInspection extends BaseJavaLocalInspectionTool {
final InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
//correct save settings
ApplicationProfileManager.getInstance().fireProfileChanged(inspectionProfile);
InspectionProfileManager.getInstance().fireProfileChanged(inspectionProfile);
//TODO lesya
/*
try {
@@ -20,7 +20,7 @@ import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.profile.ApplicationProfileManager;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.jetbrains.rest.RestBundle;
import com.jetbrains.rest.inspections.RestRoleInspection;
@@ -55,7 +55,7 @@ public class AddIgnoredRoleFix implements LocalQuickFix, LowPriorityAction {
if (!myInspection.ignoredRoles.contains(myRole)) {
myInspection.ignoredRoles.add(myRole);
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
ApplicationProfileManager.getInstance().fireProfileChanged(profile);
InspectionProfileManager.getInstance().fireProfileChanged(profile);
}
}
}
@@ -27,9 +27,9 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.Key;
import com.intellij.profile.ApplicationProfileManager;
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.util.CachedValue;
import com.intellij.psi.util.CachedValueProvider;
@@ -121,7 +121,7 @@ public class DomElementAnnotationsManagerImpl extends DomElementAnnotationsManag
}
};
ApplicationProfileManager.getInstance().addProfileChangeListener(profileChangeAdapter, project);
InspectionProfileManager.getInstance().addProfileChangeListener(profileChangeAdapter, project);
}
@Override