diff --git a/images/src/org/intellij/images/options/impl/OptionsManagerImpl.java b/images/src/org/intellij/images/options/impl/OptionsManagerImpl.java index 5e11bbc2d154..8d00ac4136fa 100644 --- a/images/src/org/intellij/images/options/impl/OptionsManagerImpl.java +++ b/images/src/org/intellij/images/options/impl/OptionsManagerImpl.java @@ -45,12 +45,7 @@ final class OptionsManagerImpl extends OptionsManager implements PersistentState @Override public Element getState() { Element element = new Element("state"); - try { - options.writeExternal(element); - } - catch (WriteExternalException e) { - throw new RuntimeException(e); - } + options.writeExternal(element); return element; } diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java index ae97e118363d..d4a53fad577d 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java @@ -105,13 +105,7 @@ public class DebuggerSettings implements Cloneable, PersistentStateComponent { myCustomRenderers.writeExternal(custom); } } - catch (WriteExternalException e) { - // ignore + catch (WriteExternalException ignore) { } return element; } diff --git a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java index d543e7b50301..50e78f090ee8 100644 --- a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.roots.libraries; import com.intellij.openapi.application.ApplicationManager; @@ -27,7 +13,6 @@ import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.roots.ModuleRootManagerTestCase; import com.intellij.testFramework.PsiTestUtil; @@ -309,14 +294,9 @@ public class LibraryTest extends ModuleRootManagerTestCase { } private static Element serialize(Library library) { - try { - Element element = new Element("root"); - library.writeExternal(element); - return element; - } - catch (WriteExternalException e) { - throw new AssertionError(e); - } + Element element = new Element("root"); + library.writeExternal(element); + return element; } public void testAddRemoveJarDirectory() { diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index c1f2a3cda79a..9a4bb4bfa61a 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection; import com.intellij.codeHighlighting.HighlightDisplayLevel; @@ -23,7 +9,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.DefaultJDOMExternalizer; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; @@ -341,7 +326,6 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool { * and bean-style getters/setters (like {@code int getToolOption(), void setToolOption(int)}) to store your options. * * @param node to store settings to. - * @throws WriteExternalException if no data should be saved for this component. */ public void writeSettings(@NotNull Element node) { if (useNewSerializer()) { diff --git a/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java b/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java index 87047edd3636..44ee6f3cecfe 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/ex/ScopeToolState.java @@ -156,7 +156,7 @@ public class ScopeToolState { throw e; } catch (Exception e) { - throw new WriteExternalException("Can't write settings for tool #" + entry.getShortName(), e); + throw new RuntimeException("Can't write settings for tool #" + entry.getShortName(), e); } } diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java index 5546581a0f55..f24c879d55fc 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettings.java @@ -1,3 +1,4 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.codeStyle; import com.intellij.configurationStore.UnknownElementCollector; @@ -865,9 +866,6 @@ public class CodeStyleSettings extends LegacyCodeStyleSettings myUnknownElementWriter.write(element, getCustomSettingsValues(), CustomCodeStyleSettings::getTagName, settings -> { CustomCodeStyleSettings parentCustomSettings = parentSettings.getCustomSettings(settings.getClass()); - if (parentCustomSettings == null) { - throw new WriteExternalException("Custom settings are null for " + settings.getClass()); - } settings.writeExternal(element, parentCustomSettings); }); diff --git a/platform/platform-api/src/com/intellij/util/config/Externalizer.java b/platform/platform-api/src/com/intellij/util/config/Externalizer.java index 97effcd8efa5..f3decd8fec8f 100644 --- a/platform/platform-api/src/com/intellij/util/config/Externalizer.java +++ b/platform/platform-api/src/com/intellij/util/config/Externalizer.java @@ -1,24 +1,9 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util.config; import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.WriteExternalException; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -78,15 +63,10 @@ public interface Externalizer { @Override public void writeValue(Element dataElement, T value) { - try { - value.writeExternal(dataElement); - } - catch (WriteExternalException e) { - throw new RuntimeException(e); - } + value.writeExternal(dataElement); } - public static FactoryBased create(Factory factory) { + static FactoryBased create(Factory factory) { return new FactoryBased<>(factory); } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.java b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.java index 14d651c37aec..d071c0be2278 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/customization/CustomActionsSchema.java @@ -232,17 +232,12 @@ public class CustomActionsSchema implements PersistentStateComponent { @Override public Element getState() { Element element = new Element("state"); - try { - //noinspection deprecation - DefaultJDOMExternalizer.writeExternal(this, element); - for (ActionUrl group : myActions) { - Element groupElement = new Element(GROUP); - group.writeExternal(groupElement); - element.addContent(groupElement); - } - } - catch (WriteExternalException e) { - throw new RuntimeException(e); + //noinspection deprecation + DefaultJDOMExternalizer.writeExternal(this, element); + for (ActionUrl group : myActions) { + Element groupElement = new Element(GROUP); + group.writeExternal(groupElement); + element.addContent(groupElement); } writeIcons(element); return element; diff --git a/platform/util/src/com/intellij/openapi/util/WriteExternalException.java b/platform/util/src/com/intellij/openapi/util/WriteExternalException.java index 586a2b520337..341dc22e81ec 100644 --- a/platform/util/src/com/intellij/openapi/util/WriteExternalException.java +++ b/platform/util/src/com/intellij/openapi/util/WriteExternalException.java @@ -1,18 +1,4 @@ -/* - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.util; /** @@ -31,8 +17,4 @@ public class WriteExternalException extends RuntimeException { public WriteExternalException(String message, Throwable cause) { super(message, cause); } - - public WriteExternalException(Throwable cause) { - super(cause); - } } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/ui/ExternalizableStringSet.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/ui/ExternalizableStringSet.java index a6164c28a1e2..f03003f2c5d3 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/ui/ExternalizableStringSet.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/ui/ExternalizableStringSet.java @@ -17,7 +17,6 @@ package com.siyeh.ig.ui; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.OrderedSet; @@ -78,10 +77,11 @@ public class ExternalizableStringSet extends OrderedSet } @Override - public void writeExternal(Element element) throws WriteExternalException { + public void writeExternal(Element element) { if (hasDefaultValues()) { return; } + for (String value : this) { if (value != null) { final Element item = new Element(ITEM); @@ -95,12 +95,12 @@ public class ExternalizableStringSet extends OrderedSet * Write this ExternalizableStringSet to the specified element, with the specified name, if it has non-default values. * @param element the element to write to. * @param name the name of the option. - * @throws WriteExternalException */ - public void writeSettings(Element element, String name) throws WriteExternalException { + public void writeSettings(Element element, String name) { if (hasDefaultValues()) { return; } + final Element optionElement = new Element("option").setAttribute("name", name); final Element valueElement = new Element("value"); writeExternal(valueElement); diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java index 3ec45abbce01..664283d8b417 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntConfigurationImpl.java @@ -163,36 +163,30 @@ public class AntConfigurationImpl extends AntConfigurationBase implements Persis @Override public Element getState() { - try { - final Element state = new Element("state"); - getProperties().writeExternal(state); - ApplicationManager.getApplication().runReadAction(() -> { - for (final AntBuildFileBase buildFile : myBuildFiles) { - final Element element = new Element(BUILD_FILE); - //noinspection ConstantConditions - element.setAttribute(URL, buildFile.getVirtualFile().getUrl()); - buildFile.writeProperties(element); - saveEvents(element, buildFile); - state.addContent(element); - } + final Element state = new Element("state"); + getProperties().writeExternal(state); + ApplicationManager.getApplication().runReadAction(() -> { + for (final AntBuildFileBase buildFile : myBuildFiles) { + final Element element = new Element(BUILD_FILE); + //noinspection ConstantConditions + element.setAttribute(URL, buildFile.getVirtualFile().getUrl()); + buildFile.writeProperties(element); + saveEvents(element, buildFile); + state.addContent(element); + } - final List files = new ArrayList<>(myAntFileToContextFileMap.keySet()); - // sort in order to minimize changes - Collections.sort(files, Comparator.comparing(VirtualFile::getUrl)); - for (VirtualFile file : files) { - final Element element = new Element(CONTEXT_MAPPING); - final VirtualFile contextFile = myAntFileToContextFileMap.get(file); - element.setAttribute(URL, file.getUrl()); - element.setAttribute(CONTEXT, contextFile.getUrl()); - state.addContent(element); - } - }); - return state; - } - catch (WriteExternalException e) { - LOG.error(e); - return null; - } + final List files = new ArrayList<>(myAntFileToContextFileMap.keySet()); + // sort in order to minimize changes + Collections.sort(files, Comparator.comparing(VirtualFile::getUrl)); + for (VirtualFile file : files) { + final Element element = new Element(CONTEXT_MAPPING); + final VirtualFile contextFile = myAntFileToContextFileMap.get(file); + element.setAttribute(URL, file.getUrl()); + element.setAttribute(CONTEXT, contextFile.getUrl()); + state.addContent(element); + } + }); + return state; } @Override diff --git a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntWorkspaceConfiguration.java b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntWorkspaceConfiguration.java index 40067bdd21b2..f7cf1740ce21 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/impl/AntWorkspaceConfiguration.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/impl/AntWorkspaceConfiguration.java @@ -35,15 +35,9 @@ public class AntWorkspaceConfiguration implements PersistentStateComponent