From e26403c578267276ef09f48d7b25c567caebb635 Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Thu, 4 Jul 2024 17:59:17 +0200 Subject: [PATCH] added backward compatibility for TelemetryMessageBuilder Signed-off-by: Andre Dietisheim --- .../core/service/TelemetryMessageBuilder.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/redhat/devtools/intellij/telemetry/core/service/TelemetryMessageBuilder.java b/src/main/java/com/redhat/devtools/intellij/telemetry/core/service/TelemetryMessageBuilder.java index f4eb122..49e9b3a 100644 --- a/src/main/java/com/redhat/devtools/intellij/telemetry/core/service/TelemetryMessageBuilder.java +++ b/src/main/java/com/redhat/devtools/intellij/telemetry/core/service/TelemetryMessageBuilder.java @@ -11,6 +11,7 @@ package com.redhat.devtools.intellij.telemetry.core.service; import com.intellij.ide.AppLifecycleListener; +import com.intellij.ide.plugins.cl.PluginAwareClassLoader; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.extensions.PluginDescriptor; import com.intellij.util.messages.MessageBusConnection; @@ -38,6 +39,11 @@ public class TelemetryMessageBuilder { private final IService telemetryFacade; private final IService feedbackFacade; + @Deprecated + public TelemetryMessageBuilder(ClassLoader classLoader) { + this(getDescriptor(classLoader)); + } + public TelemetryMessageBuilder(PluginDescriptor descriptor) { this(createEnvironment(descriptor), descriptor); } @@ -251,4 +257,12 @@ private static Environment createEnvironment(PluginDescriptor descriptor) { .build(); } + private static PluginDescriptor getDescriptor(ClassLoader classLoader) { + if (classLoader instanceof PluginAwareClassLoader) { + return ((PluginAwareClassLoader) classLoader).getPluginDescriptor(); + } else { + return null; + } + } + }