From 4682057a35f6328f5137e49c358589da0cee06bf Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 28 Aug 2015 17:30:05 +0200 Subject: [PATCH] cleanup --- .../ex/EntryPointsManagerBase.java | 5 ++--- .../daemon/impl/HighlightInfoType.java | 9 +++++++-- .../daemon/impl/SeverityRegistrar.java | 8 +++----- .../InspectionProjectProfileManagerImpl.java | 11 ++--------- .../openapi/editor/colors/TextAttributesKey.java | 4 +--- .../ex/InspectionProfileManagerImpl.java | 16 ++-------------- .../intellij/execution/impl/RunManagerImpl.java | 14 ++------------ .../util/JDOMExternalizableStringList.java | 11 +++++------ .../inject/config/MethodParameterInjection.java | 5 ++--- 9 files changed, 26 insertions(+), 57 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerBase.java index bad569517aae..9539d2d598ab 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/ex/EntryPointsManagerBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -29,7 +29,6 @@ import com.intellij.openapi.extensions.impl.ExtensionPointImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizableStringList; import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.psi.PsiDocCommentOwner; @@ -140,7 +139,7 @@ public abstract class EntryPointsManagerBase extends EntryPointsManager implemen try { ADDITIONAL_ANNOTATIONS.readExternal(element); } - catch (InvalidDataException ignored) { + catch (Throwable ignored) { } } diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java index 8c5e2fa10d52..8ea97bd0835c 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoType.java @@ -139,8 +139,13 @@ public interface HighlightInfoType { return "HighlightInfoTypeImpl[severity=" + mySeverity + ", key=" + myAttributesKey + "]"; } - public void writeExternal(Element element) throws WriteExternalException { - mySeverity.writeExternal(element); + public void writeExternal(Element element) { + try { + mySeverity.writeExternal(element); + } + catch (WriteExternalException e) { + throw new RuntimeException(e); + } myAttributesKey.writeExternal(element); } diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java index da6c999f8af6..75caebfab82d 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/SeverityRegistrar.java @@ -21,10 +21,8 @@ import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.util.JDOMExternalizableStringList; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.profile.codeInspection.InspectionProfileManager; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.util.IncorrectOperationException; @@ -135,7 +133,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator list = getOrderAsList(getOrderMap()); for (HighlightSeverity severity : list) { Element info = new Element(INFO_TAG); @@ -437,7 +435,7 @@ public class SeverityRegistrar implements JDOMExternalizable, Comparator { return find(externalName); } - public void writeExternal(Element element) throws WriteExternalException { + public void writeExternal(Element element) { JDOMExternalizerUtil.writeField(element, "myExternalName", myExternalName); if (myDefaultAttributes != NULL_ATTRIBUTES) { @@ -100,7 +99,6 @@ public final class TextAttributesKey implements Comparable { } } - public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileManagerImpl.java index 38bb1d7d571a..377146963f6a 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionProfileManagerImpl.java @@ -38,8 +38,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.profile.Profile; import com.intellij.profile.codeInspection.InspectionProfileLoadUtil; import com.intellij.profile.codeInspection.InspectionProfileManager; @@ -256,23 +254,13 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple @Override public Element getState() { Element state = new Element("state"); - try { - mySeverityRegistrar.writeExternal(state); - } - catch (WriteExternalException e) { - throw new RuntimeException(e); - } + mySeverityRegistrar.writeExternal(state); return state; } @Override public void loadState(Element state) { - try { - mySeverityRegistrar.readExternal(state); - } - catch (InvalidDataException e) { - throw new RuntimeException(e); - } + mySeverityRegistrar.readExternal(state); } public InspectionProfileConvertor getConverter() { diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java index b90bc6f023b7..a356af9e1ced 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.java @@ -720,12 +720,7 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo } } - try { - myOrder.readExternal(parentNode); - } - catch (InvalidDataException e) { - throw new RuntimeException(e); - } + myOrder.readExternal(parentNode); // migration (old ids to UUIDs) readList(myOrder); @@ -734,12 +729,7 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo Element recentNode = parentNode.getChild(RECENT); if (recentNode != null) { JDOMExternalizableStringList list = new JDOMExternalizableStringList(); - try { - list.readExternal(recentNode); - } - catch (InvalidDataException e) { - throw new RuntimeException(e); - } + list.readExternal(recentNode); readList(list); for (String name : list) { RunnerAndConfigurationSettings settings = myConfigurations.get(name); diff --git a/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java b/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java index 44c9f8317880..969f8a081df4 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -18,6 +18,7 @@ package com.intellij.openapi.util; import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.ReflectionUtil; import org.jdom.Element; +import org.jdom.IllegalDataException; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -47,7 +48,7 @@ public class JDOMExternalizableStringList extends ArrayList implements J } @Override - public void readExternal(Element element) throws InvalidDataException { + public void readExternal(Element element) { clear(); Class callerClass = null; @@ -59,8 +60,7 @@ public class JDOMExternalizableStringList extends ArrayList implements J final ClassLoader classLoader = callerClass.getClassLoader(); for (Element listItemElement : listElement.getChildren(ATTR_ITEM)) { if (!ATTR_ITEM.equals(listItemElement.getName())) { - throw new InvalidDataException( - "Unable to read list item. Unknown element found: " + listItemElement.getName()); + throw new IllegalDataException("Unable to read list item. Unknown element found: " + listItemElement.getName()); } String itemClassString = listItemElement.getAttributeValue(ATTR_CLASS); Class itemClass; @@ -68,8 +68,7 @@ public class JDOMExternalizableStringList extends ArrayList implements J itemClass = Class.forName(itemClassString, true, classLoader); } catch (ClassNotFoundException ex) { - throw new InvalidDataException( - "Unable to read list item: unable to load class: " + itemClassString + " \n" + ex.getMessage()); + throw new IllegalDataException("Unable to read list item: unable to load class: " + itemClassString + " \n" + ex.getMessage()); } String listItem = listItemElement.getAttributeValue(ATTR_VALUE); diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java index 464aa38ccc03..024f822c43ad 100644 --- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java +++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/inject/config/MethodParameterInjection.java @@ -16,7 +16,6 @@ package org.intellij.plugins.intelliLang.inject.config; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizableStringList; import com.intellij.openapi.util.JDOMExternalizer; import com.intellij.openapi.util.Pair; @@ -28,6 +27,7 @@ import com.intellij.util.IncorrectOperationException; import gnu.trove.THashMap; import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport; import org.jdom.Element; +import org.jdom.IllegalDataException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -97,8 +97,7 @@ public class MethodParameterInjection extends BaseInjection { try { list.readExternal(e); } - catch (InvalidDataException e1) { - // nothing + catch (IllegalDataException ignored) { } if (list.isEmpty()) return; final boolean[] selection = new boolean[list.size()];