Skip to content

Commit

Permalink
Use old way to do ApplicationInsightsBundle so both stable and `e…
Browse files Browse the repository at this point in the history
…ap` can compile. Revert this once stable is 2020.1
  • Loading branch information
Socolin committed Mar 29, 2020
1 parent cbaea98 commit f36cc8f
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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<ResourceBundle> ourBundle;

@NotNull
public static Supplier<String> 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;
}
}

0 comments on commit f36cc8f

Please sign in to comment.