From 23cfc5c2e4f25cc0e5a0c7b36e557c74378e1aa2 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Sat, 21 Dec 2019 16:34:43 +0300 Subject: [PATCH] python bundle GitOrigin-RevId: e80fd24be0e55e6b26aa00ab333df441b8edfaaf --- python/src/com/jetbrains/python/PyBundle.java | 42 +++---------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/python/src/com/jetbrains/python/PyBundle.java b/python/src/com/jetbrains/python/PyBundle.java index e506fd3c8afd..5c02d4e917bb 100644 --- a/python/src/com/jetbrains/python/PyBundle.java +++ b/python/src/com/jetbrains/python/PyBundle.java @@ -15,49 +15,19 @@ */ package com.jetbrains.python; -import com.intellij.CommonBundle; -import com.intellij.reference.SoftReference; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.PropertyKey; -import java.lang.ref.Reference; -import java.util.ResourceBundle; +public class PyBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "com.jetbrains.python.PyBundle"; + public static final PyBundle INSTANCE = new PyBundle(); -// A copy of Ruby's. - -/** - * TODO: Copy/paste with Django and PyBDD bundles - * Resource bundle access. - */ -public class PyBundle { + private PyBundle() { super(BUNDLE); } @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - @Nullable - public static String messageOfNull(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, - @NotNull Object... params) { - return CommonBundle.messageOfNull(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls - private static final String BUNDLE = "com.jetbrains.python.PyBundle"; - - private PyBundle() { - } - - // Cached loading - private static ResourceBundle getBundle() { - ResourceBundle bundle = SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; + return INSTANCE.getMessage(key, params); } }