From 9432eb9178c56ac22a62f456d203229d1b5e73dd Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Mon, 23 Dec 2019 12:40:07 +0300 Subject: [PATCH] py bundle GitOrigin-RevId: f881a433069400ce5e23bd4b179120cd7497bbef --- .../src/com/jetbrains/python/PyPsiBundle.java | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/python/python-psi-impl/src/com/jetbrains/python/PyPsiBundle.java b/python/python-psi-impl/src/com/jetbrains/python/PyPsiBundle.java index a6af9b113ad7..4d2eccff37c3 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/PyPsiBundle.java +++ b/python/python-psi-impl/src/com/jetbrains/python/PyPsiBundle.java @@ -15,42 +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 PyPsiBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "com.jetbrains.python.PyPsiBundle"; + public static final PyPsiBundle INSTANCE = new PyPsiBundle(); -public class PyPsiBundle { + private PyPsiBundle() { 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.PyPsiBundle"; - - private PyPsiBundle() { - } - - // 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); } }