mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[plugins] ClassLoaderConfigurationData replaced with a pair of static methods
GitOrigin-RevId: e61c62fb32174f13b43d7f9ff99483ebaea1dc93
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2334617c1b
commit
f6b8636486
@@ -1,25 +0,0 @@
|
||||
// Copyright 2000-2021 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.ide.plugins;
|
||||
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public final class ClassLoaderConfigurationData {
|
||||
private ClassLoaderConfigurationData() {
|
||||
}
|
||||
|
||||
static final Set<PluginId> SEPARATE_CLASSLOADER_FOR_SUB_EXCLUDE = new ReferenceOpenHashSet<>(new PluginId[]{
|
||||
PluginId.getId("org.jetbrains.kotlin"),
|
||||
PluginId.getId("com.intellij.java"),
|
||||
});
|
||||
|
||||
public static boolean isClassloaderPerDescriptorEnabled(@NotNull PluginId pluginId, @Nullable String packagePrefix) {
|
||||
return packagePrefix != null && !SEPARATE_CLASSLOADER_FOR_SUB_EXCLUDE.contains(pluginId);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ package com.intellij.ide.plugins
|
||||
import com.intellij.diagnostic.PluginException
|
||||
import com.intellij.ide.plugins.cl.PluginClassLoader
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.lang.ClassPath
|
||||
import com.intellij.util.lang.ResourceFile
|
||||
@@ -27,6 +28,21 @@ class ClassLoaderConfigurator(
|
||||
private val coreLoader: ClassLoader = ClassLoaderConfigurator::class.java.classLoader,
|
||||
private val usePluginClassLoader: Boolean = true, /* grab classes from platform loader only if nothing is found in any of plugin dependencies */
|
||||
) {
|
||||
|
||||
companion object {
|
||||
|
||||
@ApiStatus.Internal
|
||||
@JvmStatic
|
||||
fun isMigratedToNewModel(idString: String): Boolean {
|
||||
return idString != "org.jetbrains.kotlin"
|
||||
&& idString != "com.intellij.java"
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
@JvmStatic
|
||||
fun isMigratedToNewModel(pluginId: PluginId) = isMigratedToNewModel(pluginId.idString)
|
||||
}
|
||||
|
||||
private var javaDep: Optional<IdeaPluginDescriptorImpl>? = null
|
||||
|
||||
// temporary set to produce arrays (avoid allocation for each plugin)
|
||||
@@ -60,7 +76,8 @@ class ClassLoaderConfigurator(
|
||||
dependencyPlugin: IdeaPluginDescriptorImpl) {
|
||||
for ((mainDependent, modules) in mainToModule) {
|
||||
val mainDependentClassLoader = mainDependent.classLoader as PluginClassLoader
|
||||
if (ClassLoaderConfigurationData.isClassloaderPerDescriptorEnabled(mainDependent.id, mainDependent.packagePrefix)) {
|
||||
if (mainDependent.packagePrefix != null
|
||||
&& isMigratedToNewModel(mainDependent.id)) {
|
||||
for (module in modules) {
|
||||
assert(module.packagePrefix != null)
|
||||
configureModule(module, mainDependentClassLoader,
|
||||
|
||||
@@ -280,7 +280,8 @@ object DynamicPlugins {
|
||||
|
||||
var dependencyMessage: String? = null
|
||||
processOptionalDependenciesOnPlugin(descriptor, pluginSet, isLoaded = true) { mainDescriptor, subDescriptor ->
|
||||
if (!ClassLoaderConfigurationData.isClassloaderPerDescriptorEnabled(mainDescriptor.pluginId, subDescriptor.packagePrefix)) {
|
||||
if (subDescriptor.packagePrefix == null
|
||||
|| !ClassLoaderConfigurator.isMigratedToNewModel(mainDescriptor.pluginId)) {
|
||||
dependencyMessage = "Plugin ${subDescriptor.pluginId} that optionally depends on ${descriptor.pluginId} does not have a separate classloader for the dependency"
|
||||
return@processOptionalDependenciesOnPlugin false
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
// Copyright 2000-2021 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 that can be found in the LICENSE file.
|
||||
package org.jetbrains.idea.devkit.internal
|
||||
|
||||
import com.intellij.ide.plugins.ClassLoaderConfigurationData
|
||||
import com.intellij.ide.plugins.ClassLoaderConfigurator
|
||||
import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys
|
||||
import com.intellij.openapi.application.runReadAction
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
@@ -209,7 +208,8 @@ class AnalyzeUnloadablePluginsAction : AnAction() {
|
||||
continue
|
||||
}
|
||||
descriptor.pluginId?.let { pluginId ->
|
||||
if (!ClassLoaderConfigurationData.isClassloaderPerDescriptorEnabled(PluginId.getId(pluginId), depIdeaPlugin.`package`.rawText)) {
|
||||
if (depIdeaPlugin.`package`.rawText == null
|
||||
|| !ClassLoaderConfigurator.isMigratedToNewModel(pluginId)) {
|
||||
dependenciesWithoutSeparateClassloaders.add(pluginId)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user