diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index 9709dcd8592d..a1822af46b1f 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -67,8 +67,6 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.InspectionProfileImpl"); @NonNls private static final String VALID_VERSION = "1.0"; @NonNls private static final String VERSION_TAG = "version"; - @NonNls private static final String PROFILE_NAME_TAG = "profile_name"; - @NonNls private static final String ROOT_ELEMENT_TAG = "inspections"; @NonNls private static final String USED_LEVELS = "used_levels"; @NonNls private static final String IS_LOCKED = "is_locked"; @NonNls private static final String DESCRIPTION = "description"; @@ -313,12 +311,12 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, element.addContent(new Element(DESCRIPTION).addContent(myDescription)); } synchronized (myExternalInfo) { - if (!myInitialized) { + if (!myInitialized) { for (Element el : myDeinstalledInspectionsSettings.values()) { element.addContent(el.clone()); } - return; - } + return; + } } Map diffMap = getDisplayLevelMap(); @@ -559,7 +557,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, try { tools = createTools(project); } - catch (ProcessCanceledException e) { + catch (ProcessCanceledException ignored) { return false; } final Map> dependencies = new HashMap>(); @@ -821,19 +819,6 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, myDescription = description; } - public Element saveToDocument() throws WriteExternalException { - if (isLocal()) { - Element root = new Element(ROOT_ELEMENT_TAG); - root.setAttribute(PROFILE_NAME_TAG, myName); - writeExternal(root); - //myVisibleTreeState.writeExternal(root); - return root; - } - else { - return null; - } - } - @Override public void convert(@NotNull Element element, @NotNull Project project) { initInspectionTools(project); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java index 7d8c01c82d81..77a3cde87726 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java @@ -66,7 +66,6 @@ import java.util.concurrent.atomic.AtomicBoolean; */ public class InspectionProfileManagerImpl extends InspectionProfileManager implements SeverityProvider, ExportableComponent, JDOMExternalizable, NamedComponent { - private final InspectionToolRegistrar myRegistrar; private final SchemesManager mySchemesManager; private final AtomicBoolean myProfilesAreInitialized = new AtomicBoolean(false); @@ -86,20 +85,33 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple @NotNull @Override public InspectionProfileImpl readScheme(@NotNull Element element) { - InspectionProfileImpl profile = new InspectionProfileImpl(InspectionProfileLoadUtil.getProfileName(element), myRegistrar, InspectionProfileManagerImpl.this); - read(profile, element); + final InspectionProfileImpl profile = new InspectionProfileImpl(InspectionProfileLoadUtil.getProfileName(element), myRegistrar, InspectionProfileManagerImpl.this); + try { + profile.readExternal(element); + } + catch (Exception ignored) { + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + Messages.showErrorDialog(InspectionsBundle.message("inspection.error.loading.message", 0, profile.getName()), + InspectionsBundle.message("inspection.errors.occurred.dialog.title")); + } + }, ModalityState.NON_MODAL); + } return profile; } @Override - public boolean shouldBeSaved(@NotNull final InspectionProfileImpl scheme) { - return scheme.wasInitialized(); + public boolean shouldBeSaved(@NotNull InspectionProfileImpl scheme) { + return !scheme.isLocal() && scheme.wasInitialized(); } - @Override - public Element writeScheme(@NotNull final InspectionProfileImpl scheme) throws WriteExternalException { - return scheme.saveToDocument(); + public Element writeScheme(@NotNull InspectionProfileImpl scheme) throws WriteExternalException { + Element root = new Element("inspections"); + root.setAttribute("profile_name", scheme.myName); + scheme.writeExternal(root); + return root; } @Override @@ -128,21 +140,6 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple mySeverityRegistrar = new SeverityRegistrar(messageBus); } - private static void read(@NotNull final InspectionProfileImpl profile, @NotNull Element element) { - try { - profile.readExternal(element); - } - catch (Exception ignored) { - ApplicationManager.getApplication().invokeLater(new Runnable() { - @Override - public void run() { - Messages.showErrorDialog(InspectionsBundle.message("inspection.error.loading.message", 0, profile.getName()), - InspectionsBundle.message("inspection.errors.occurred.dialog.title")); - } - }, ModalityState.NON_MODAL); - } - } - @NotNull private static InspectionProfileImpl createSampleProfile() { return new InspectionProfileImpl("Default");