diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java index 417c687b9247..a5348ac1a7f2 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/TestEditorManagerImpl.java @@ -30,6 +30,7 @@ import com.intellij.testFramework.LightVirtualFile; import com.intellij.util.IncorrectOperationException; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.concurrency.Promise; import org.jetbrains.concurrency.Promises; @@ -270,7 +271,7 @@ final class TestEditorManagerImpl extends FileEditorManagerEx implements Disposa @Override @NotNull - public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { + public FileEditorState readState(@Nullable Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { throw new IncorrectOperationException(); } diff --git a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/PsiAwareTextEditorProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/PsiAwareTextEditorProvider.java index 07acbeb129c5..55b672944917 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/PsiAwareTextEditorProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileEditor/impl/text/PsiAwareTextEditorProvider.java @@ -23,6 +23,7 @@ import com.intellij.psi.PsiDocumentManager; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class PsiAwareTextEditorProvider extends TextEditorProvider { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorProvider"); @@ -37,11 +38,11 @@ public class PsiAwareTextEditorProvider extends TextEditorProvider { @Override @NotNull - public FileEditorState readState(@NotNull final Element element, @NotNull final Project project, @NotNull final VirtualFile file) { + public FileEditorState readState(@Nullable Element element, @NotNull final Project project, @NotNull final VirtualFile file) { final TextEditorState state = (TextEditorState)super.readState(element, project, file); // Foldings - Element child = element.getChild(FOLDING_ELEMENT); + Element child = element == null ? null : element.getChild(FOLDING_ELEMENT); if (child != null) { Document document = FileDocumentManager.getInstance().getCachedDocument(file); if (document == null) { diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java index 0a19f2360dff..57cb883c149f 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorProvider.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.fileEditor; import com.intellij.openapi.extensions.ExtensionPointName; @@ -24,6 +10,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Should be registered via {@link #EP_FILE_EDITOR_PROVIDER}. @@ -71,7 +58,7 @@ public interface FileEditorProvider { * Use {@link FileEditorState#INSTANCE} as default implementation */ @NotNull - default FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { + default FileEditorState readState(@Nullable Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { return FileEditorState.INSTANCE; } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java index c40b712289e0..b2be24582843 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorHistoryManager.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.openapi.fileEditor.impl; import com.intellij.ide.ui.UISettings; @@ -31,7 +17,6 @@ import com.intellij.openapi.project.DumbAwareRunnable; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; @@ -216,7 +201,7 @@ public final class EditorHistoryManager implements PersistentStateComponent result = new ArrayList<>(myEntriesList.size()); for (HistoryEntry entry : myEntriesList) { VirtualFile file = entry.getFile(); @@ -306,8 +291,7 @@ public final class EditorHistoryManager implements PersistentStateComponent caretElements = element.getChildren(CARET_ELEMENT); diff --git a/platform/testFramework/src/com/intellij/mock/Mock.java b/platform/testFramework/src/com/intellij/mock/Mock.java index 394946c33d7b..4e4632a80419 100644 --- a/platform/testFramework/src/com/intellij/mock/Mock.java +++ b/platform/testFramework/src/com/intellij/mock/Mock.java @@ -681,7 +681,7 @@ public class Mock { @Override @NotNull - public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { + public FileEditorState readState(@Nullable Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { throw new UnsupportedOperationException(); } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.java index 218e6f3468ca..80b35ec70c92 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditorProvider.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.lang.properties.editor; import com.intellij.lang.properties.PropertiesImplUtil; @@ -34,6 +20,7 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class ResourceBundleEditorProvider extends FileTypeFactory implements FileEditorProvider, DumbAware { private static final ResourceBundleFileType RESOURCE_BUNDLE_FILE_TYPE = new ResourceBundleFileType(); @@ -73,7 +60,7 @@ public class ResourceBundleEditorProvider extends FileTypeFactory implements Fil @Override @NotNull - public FileEditorState readState(@NotNull Element element, @NotNull Project project, @NotNull VirtualFile file) { + public FileEditorState readState(@Nullable Element element, @NotNull Project project, @NotNull VirtualFile file) { return new ResourceBundleEditor.ResourceBundleEditorState(null); } diff --git a/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java b/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java index c57525c8903a..f7fb5cd08a6c 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/DesignerEditorState.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2012 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.designer; import com.intellij.openapi.editor.Document; @@ -22,6 +8,7 @@ import com.intellij.openapi.fileEditor.FileEditorStateLevel; import com.intellij.openapi.vfs.VirtualFile; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Alexander Lobas @@ -70,16 +57,15 @@ public class DesignerEditorState implements FileEditorState { * @see com.intellij.openapi.fileEditor.FileEditorProvider#readState(org.jdom.Element, com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile) */ @NotNull - public static FileEditorState readState(@NotNull Element sourceElement, @NotNull VirtualFile file, double defaultZoom) { + public static FileEditorState readState(@Nullable Element sourceElement, @NotNull VirtualFile file, double defaultZoom) { double zoom = defaultZoom; - - try { - zoom = Double.parseDouble(sourceElement.getAttributeValue(DESIGNER_ZOOM)); + if (sourceElement != null) { + try { + zoom = Double.parseDouble(sourceElement.getAttributeValue(DESIGNER_ZOOM)); + } + catch (Throwable ignored) { + } } - catch (Throwable e) { - // ignore - } - return new DesignerEditorState(file, zoom); } diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.java b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.java index 24310a4db62e..8f8ae3f41780 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/editor/UIFormEditorProvider.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.uiDesigner.editor; import com.intellij.openapi.diagnostic.Logger; @@ -29,6 +15,7 @@ import com.intellij.testFramework.LightVirtualFile; import com.intellij.util.ArrayUtil; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public final class UIFormEditorProvider implements FileEditorProvider, DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.editor.UIFormEditorProvider"); @@ -49,7 +36,7 @@ public final class UIFormEditorProvider implements FileEditorProvider, DumbAware @Override @NotNull - public FileEditorState readState(@NotNull final Element element, @NotNull final Project project, @NotNull final VirtualFile file){ + public FileEditorState readState(@Nullable Element element, @NotNull final Project project, @NotNull final VirtualFile file){ //TODO[anton,vova] implement return new MyEditorState(-1, ArrayUtil.EMPTY_STRING_ARRAY); } diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorProvider.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorProvider.java index e9f5f0a4ac52..ef4834bf2bd8 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorProvider.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/editor/IpnbEditorProvider.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 org.jetbrains.plugins.ipnb.editor; import com.intellij.openapi.fileEditor.FileEditor; @@ -6,10 +7,12 @@ import com.intellij.openapi.fileEditor.FileEditorProvider; import com.intellij.openapi.fileEditor.FileEditorState; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.ipnb.IpnbFileType; /** @@ -32,10 +35,10 @@ public class IpnbEditorProvider implements FileEditorProvider, DumbAware { @NotNull @Override - public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { + public FileEditorState readState(@Nullable Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) { final IpnbEditorState state = new IpnbEditorState(-1, 0); - final Element child = sourceElement.getChild(SELECTED_CELL); - state.setSelectedIndex(child == null ? 0 : Integer.parseInt(child.getAttributeValue(ID))); + final Element child = sourceElement == null ? null : sourceElement.getChild(SELECTED_CELL); + state.setSelectedIndex(child == null ? 0 : StringUtil.parseInt(child.getAttributeValue(ID), 0)); return state; }