From f36cc8f87e59227bf13fd24de42696f91c0f7130 Mon Sep 17 00:00:00 2001 From: Socolin Date: Sun, 29 Mar 2020 02:42:36 -0400 Subject: [PATCH] Use old way to do `ApplicationInsightsBundle` so both `stable` and `eap` can compile. Revert this once stable is 2020.1 --- .../ApplicationInsightsBundle.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/fr/socolin/applicationinsights/ApplicationInsightsBundle.java b/src/main/java/fr/socolin/applicationinsights/ApplicationInsightsBundle.java index 4315c23..51ae457 100644 --- a/src/main/java/fr/socolin/applicationinsights/ApplicationInsightsBundle.java +++ b/src/main/java/fr/socolin/applicationinsights/ApplicationInsightsBundle.java @@ -1,30 +1,34 @@ package fr.socolin.applicationinsights; -import com.intellij.DynamicBundle; +import com.intellij.CommonBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.util.function.Supplier; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.util.ResourceBundle; -public class ApplicationInsightsBundle extends DynamicBundle { - @NonNls - private static final String BUNDLE = "messages.ApplicationInsightsBundle"; - private static final ApplicationInsightsBundle INSTANCE = new ApplicationInsightsBundle(); - private ApplicationInsightsBundle() { - super(BUNDLE); - } +public class ApplicationInsightsBundle { - @NotNull - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { - return INSTANCE.getMessage(key, params); + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return CommonBundle.message(getBundle(), key, params); } + @NonNls + public static final String BUNDLE = "messages.ApplicationInsightsBundle"; + private static Reference ourBundle; - @NotNull - public static Supplier messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { - return INSTANCE.getLazyMessage(key, params); + private ApplicationInsightsBundle() { } + private static ResourceBundle getBundle() { + ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); + if (bundle == null) { + bundle = ResourceBundle.getBundle(BUNDLE); + ourBundle = new SoftReference<>(bundle); + } + return bundle; + } }