From 059beaf7230027bba15cecbdf15994adf7ab6c97 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Thu, 23 Dec 2021 09:03:51 +0100 Subject: [PATCH] intellij.platform.images.copyright as a product module GitOrigin-RevId: a4042fb1fc45ea773af78be3657e3efe974722a5 --- .idea/modules.xml | 1 + .../src/META-INF/IdeaPlugin.xml | 1 + .../intellij.platform.images.copyright.iml | 16 ++++++++++++ .../intellij.platform.images.copyright.xml | 1 + .../images/copyright/SvgCopyrightUpdater.java | 0 images/intellij.platform.images.iml | 1 - images/resources/META-INF/plugin.xml | 15 +++++------ .../intellij/images}/ImagesIcons.java | 4 +-- .../images/fileTypes/impl/ImageFileType.java | 4 +-- .../images/fileTypes/impl/SvgFileType.java | 18 ++----------- .../thumbnail/impl/ThumbnailViewImpl.java | 4 +-- .../images/ui/ThumbnailComponentUI.java | 4 +-- .../ide/plugins/ClassPathXmlPathResolver.kt | 26 ++++++++++++++----- .../ide/plugins/PluginDescriptorLoader.kt | 3 +++ .../com/intellij/ide/plugins/dataLoader.kt | 5 +++- .../ideCoreSrc/META-INF/PyCharmCorePlugin.xml | 1 + 16 files changed, 63 insertions(+), 41 deletions(-) create mode 100644 images/intellij.platform.images.copyright/intellij.platform.images.copyright.iml rename images/{ => intellij.platform.images.copyright}/resources/intellij.platform.images.copyright.xml (87%) rename images/{ => intellij.platform.images.copyright}/src/org/intellij/images/copyright/SvgCopyrightUpdater.java (100%) rename images/src/{icons => org/intellij/images}/ImagesIcons.java (91%) diff --git a/.idea/modules.xml b/.idea/modules.xml index f953b05be22d..5a876373facb 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -737,6 +737,7 @@ + diff --git a/community-resources/src/META-INF/IdeaPlugin.xml b/community-resources/src/META-INF/IdeaPlugin.xml index 0da2f49c986b..8f20ba94fe98 100644 --- a/community-resources/src/META-INF/IdeaPlugin.xml +++ b/community-resources/src/META-INF/IdeaPlugin.xml @@ -25,5 +25,6 @@ + diff --git a/images/intellij.platform.images.copyright/intellij.platform.images.copyright.iml b/images/intellij.platform.images.copyright/intellij.platform.images.copyright.iml new file mode 100644 index 000000000000..8a26d55d4e37 --- /dev/null +++ b/images/intellij.platform.images.copyright/intellij.platform.images.copyright.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/images/resources/intellij.platform.images.copyright.xml b/images/intellij.platform.images.copyright/resources/intellij.platform.images.copyright.xml similarity index 87% rename from images/resources/intellij.platform.images.copyright.xml rename to images/intellij.platform.images.copyright/resources/intellij.platform.images.copyright.xml index c5520c13ab33..f857a23d0481 100644 --- a/images/resources/intellij.platform.images.copyright.xml +++ b/images/intellij.platform.images.copyright/resources/intellij.platform.images.copyright.xml @@ -1,5 +1,6 @@ + diff --git a/images/src/org/intellij/images/copyright/SvgCopyrightUpdater.java b/images/intellij.platform.images.copyright/src/org/intellij/images/copyright/SvgCopyrightUpdater.java similarity index 100% rename from images/src/org/intellij/images/copyright/SvgCopyrightUpdater.java rename to images/intellij.platform.images.copyright/src/org/intellij/images/copyright/SvgCopyrightUpdater.java diff --git a/images/intellij.platform.images.iml b/images/intellij.platform.images.iml index 35bea0f82d9e..d04dcb74e8a9 100644 --- a/images/intellij.platform.images.iml +++ b/images/intellij.platform.images.iml @@ -16,6 +16,5 @@ - \ No newline at end of file diff --git a/images/resources/META-INF/plugin.xml b/images/resources/META-INF/plugin.xml index ec4b80a6928c..d9cfeb5db3aa 100644 --- a/images/resources/META-INF/plugin.xml +++ b/images/resources/META-INF/plugin.xml @@ -1,20 +1,19 @@ - + JetBrains Images com.intellij.platform.images Adds support for image file type preview, SVG file type contents language - - - - messages.ImagesBundle - com.intellij.modules.lang - com.intellij.modules.xml + + + + + @@ -67,7 +66,7 @@ + icon="org.intellij.images.ImagesIcons.ToggleTransparencyChessboard"> diff --git a/images/src/icons/ImagesIcons.java b/images/src/org/intellij/images/ImagesIcons.java similarity index 91% rename from images/src/icons/ImagesIcons.java rename to images/src/org/intellij/images/ImagesIcons.java index 9d936330c634..57d1e7eec124 100644 --- a/images/src/icons/ImagesIcons.java +++ b/images/src/org/intellij/images/ImagesIcons.java @@ -1,5 +1,5 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package icons; +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.intellij.images; import com.intellij.ui.IconManager; import org.jetbrains.annotations.NotNull; diff --git a/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java b/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java index 4de29a330587..d11ffb1ac771 100644 --- a/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java +++ b/images/src/org/intellij/images/fileTypes/impl/ImageFileType.java @@ -1,9 +1,9 @@ -// Copyright 2000-2019 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. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.intellij.images.fileTypes.impl; import com.intellij.openapi.fileTypes.UserBinaryFileType; -import icons.ImagesIcons; import org.intellij.images.ImagesBundle; +import org.intellij.images.ImagesIcons; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; diff --git a/images/src/org/intellij/images/fileTypes/impl/SvgFileType.java b/images/src/org/intellij/images/fileTypes/impl/SvgFileType.java index 5efb35d385c5..34add281615a 100644 --- a/images/src/org/intellij/images/fileTypes/impl/SvgFileType.java +++ b/images/src/org/intellij/images/fileTypes/impl/SvgFileType.java @@ -1,24 +1,10 @@ -/* - * 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-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.intellij.images.fileTypes.impl; import com.intellij.ide.IdeBundle; import com.intellij.ide.highlighter.XmlLikeFileType; import com.intellij.openapi.fileTypes.UIBasedFileType; -import icons.ImagesIcons; +import org.intellij.images.ImagesIcons; import org.jetbrains.annotations.NotNull; import javax.swing.*; diff --git a/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java b/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java index 930a8201e289..d56ce7aab65e 100644 --- a/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java +++ b/images/src/org/intellij/images/thumbnail/impl/ThumbnailViewImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 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. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.intellij.images.thumbnail.impl; @@ -8,8 +8,8 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowAnchor; import com.intellij.openapi.wm.ToolWindowManager; -import icons.ImagesIcons; import org.intellij.images.ImagesBundle; +import org.intellij.images.ImagesIcons; import org.intellij.images.editor.ImageZoomModel; import org.intellij.images.editor.actionSystem.ImageEditorActions; import org.intellij.images.search.TagFilter; diff --git a/images/src/org/intellij/images/ui/ThumbnailComponentUI.java b/images/src/org/intellij/images/ui/ThumbnailComponentUI.java index 648a25a03924..904c46c4dcd6 100644 --- a/images/src/org/intellij/images/ui/ThumbnailComponentUI.java +++ b/images/src/org/intellij/images/ui/ThumbnailComponentUI.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 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. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.intellij.images.ui; import com.intellij.ide.ui.UISettings; @@ -6,8 +6,8 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.JBColor; import com.intellij.util.ui.StartupUiUtil; -import icons.ImagesIcons; import org.intellij.images.ImagesBundle; +import org.intellij.images.ImagesIcons; import org.intellij.images.editor.ImageDocument; import org.jetbrains.annotations.NonNls; diff --git a/platform/core-impl/src/com/intellij/ide/plugins/ClassPathXmlPathResolver.kt b/platform/core-impl/src/com/intellij/ide/plugins/ClassPathXmlPathResolver.kt index e74ba7f41f42..9307bb5b3880 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/ClassPathXmlPathResolver.kt +++ b/platform/core-impl/src/com/intellij/ide/plugins/ClassPathXmlPathResolver.kt @@ -1,6 +1,7 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.ide.plugins +import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.createNonCoalescingXmlStreamReader import com.intellij.util.lang.UrlClassLoader import org.codehaus.stax2.XMLStreamReader2 @@ -60,13 +61,24 @@ internal class ClassPathXmlPathResolver(private val classLoader: ClassLoader, va return descriptor } - if (isRunningFromSources && path.startsWith("intellij.") && dataLoader is LocalFsDataLoader) { - try { - resource = Files.readAllBytes(dataLoader.basePath.parent.resolve("${path.substring(0, path.length - 4)}/$path")) + if (isRunningFromSources && path.startsWith("intellij.")) { + if (dataLoader is LocalFsDataLoader) { + try { + resource = Files.readAllBytes(dataLoader.basePath.parent.resolve("${path.substring(0, path.length - 4)}/$path")) + } + catch (e: Exception) { + throw RuntimeException("Cannot resolve $path (dataLoader=$dataLoader, classLoader=$classLoader). " + + "Please ensure that project is built (Build -> Build Project).", e) + } } - catch (e: Exception) { - throw RuntimeException("Cannot resolve $path (dataLoader=$dataLoader, classLoader=$classLoader). " + - "Please ensure that project is built (Build -> Build Project).", e) + else if (dataLoader.emptyDescriptorIfCannotResolve) { + Logger.getInstance(ClassPathXmlPathResolver::class.java).warn( + "Cannot resolve $path (dataLoader=$dataLoader, classLoader=$classLoader). " + + "Please ensure that project is built (Build -> Build Project)." + ) + val descriptor = RawPluginDescriptor() + descriptor.`package` = "unresolved.${path.removeSuffix(".xml")}" + return descriptor } } diff --git a/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt b/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt index 2a816a8dc9a8..ec00f2a15b23 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt +++ b/platform/core-impl/src/com/intellij/ide/plugins/PluginDescriptorLoader.kt @@ -465,6 +465,9 @@ private fun loadCoreProductPlugin(reader: XMLStreamReader2, override val pool: ZipFilePool get() = throw IllegalStateException("must be not called") + override val emptyDescriptorIfCannotResolve: Boolean + get() = true + override fun load(path: String) = throw IllegalStateException("must be not called") override fun toString() = "product classpath" diff --git a/platform/core-impl/src/com/intellij/ide/plugins/dataLoader.kt b/platform/core-impl/src/com/intellij/ide/plugins/dataLoader.kt index 3b882f145bee..a5e1aadd7303 100644 --- a/platform/core-impl/src/com/intellij/ide/plugins/dataLoader.kt +++ b/platform/core-impl/src/com/intellij/ide/plugins/dataLoader.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.ide.plugins import com.intellij.util.lang.ZipFilePool @@ -12,6 +12,9 @@ import java.nio.file.Path interface DataLoader { val pool: ZipFilePool? + val emptyDescriptorIfCannotResolve: Boolean + get() = false + fun isExcludedFromSubSearch(jarFile: Path): Boolean = false fun load(path: String): InputStream? diff --git a/python/ideCoreSrc/META-INF/PyCharmCorePlugin.xml b/python/ideCoreSrc/META-INF/PyCharmCorePlugin.xml index 4f18dcf8edeb..ffaaa58c901c 100644 --- a/python/ideCoreSrc/META-INF/PyCharmCorePlugin.xml +++ b/python/ideCoreSrc/META-INF/PyCharmCorePlugin.xml @@ -5,6 +5,7 @@ +