mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
detect plugins that use core classloader (use-idea-classloader=true)
GitOrigin-RevId: 0ffaed5164ebcdb8208a2afefa2200e6acb51b24
This commit is contained in:
committed by
intellij-monorepo-bot
parent
173b22b49d
commit
15d8a5200d
@@ -411,13 +411,33 @@ public class PluginManagerCore {
|
||||
if (className.startsWith("java.") || className.startsWith("javax.") || className.startsWith("kotlin.") || className.startsWith("groovy.")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (IdeaPluginDescriptor descriptor : getPlugins()) {
|
||||
if (hasLoadedClass(className, descriptor.getPluginClassLoader())) {
|
||||
return descriptor.getPluginId();
|
||||
}
|
||||
IdeaPluginDescriptor result = null;
|
||||
for (IdeaPluginDescriptor o : getPlugins()) {
|
||||
if (!hasLoadedClass(className, o.getPluginClassLoader())) continue;
|
||||
result = o;
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
if (result == null) return null;
|
||||
|
||||
// return if the found plugin is not "core" or the package is obviously "core"
|
||||
if (!result.getPluginId().getIdString().equals(CORE_PLUGIN_ID) ||
|
||||
className.startsWith("com.jetbrains.") || className.startsWith("org.jetbrains.") ||
|
||||
className.startsWith("com.intellij.") || className.startsWith("org.intellij.") ||
|
||||
className.startsWith("git4idea.") || className.startsWith("com.android.")) {
|
||||
return result.getPluginId();
|
||||
}
|
||||
// otherwise we need to check plugins with use-idea-classloader="true"
|
||||
String root = PathManager.getResourceRoot(result.getPluginClassLoader(), "/" + className.replace('.', '/') + ".class");
|
||||
if (root == null) return null;
|
||||
for (IdeaPluginDescriptor o : getPlugins()) {
|
||||
if (!o.getUseIdeaClassLoader()) continue;
|
||||
File path = o.getPath();
|
||||
String pluginPath = path == null ? null : FileUtil.toSystemIndependentName(path.getPath());
|
||||
if (pluginPath == null || !root.startsWith(pluginPath)) continue;
|
||||
result = o;
|
||||
break;
|
||||
}
|
||||
return result.getPluginId();
|
||||
}
|
||||
|
||||
private static boolean hasLoadedClass(@NotNull String className, ClassLoader loader) {
|
||||
|
||||
Reference in New Issue
Block a user