From d73aa0a711481fe8207bbfa270257d404e404751 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Fri, 20 Dec 2019 17:56:43 +0300 Subject: [PATCH] more bundles GitOrigin-RevId: 5f1d33872141e8a0b14596a030e144ec27c55b03 --- .../generate/GroovyCodeInsightBundle.java | 28 ++++------------ .../plugins/groovy/doc/GroovyDocBundle.java | 27 ++++----------- .../refactoring/GroovyRefactoringBundle.java | 33 +++++-------------- 3 files changed, 22 insertions(+), 66 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java index ff6576dd0a26..08bd10fc40b0 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java @@ -15,33 +15,19 @@ */ package org.jetbrains.plugins.groovy.actions.generate; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.util.ResourceBundle; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; +public class GroovyCodeInsightBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "org.jetbrains.plugins.groovy.actions.generate.GroovyCodeInsightBundle"; + private static final GroovyCodeInsightBundle INSTANCE = new GroovyCodeInsightBundle(); -import com.intellij.CommonBundle; - -public class GroovyCodeInsightBundle { + private GroovyCodeInsightBundle() { super(BUNDLE); } + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls - private static final String BUNDLE = "org.jetbrains.plugins.groovy.actions.generate.GroovyCodeInsightBundle"; - - 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; + return INSTANCE.getMessage(key, params); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java index 95b86c597df8..7287d8a0510a 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java @@ -16,33 +16,20 @@ package org.jetbrains.plugins.groovy.doc; -import com.intellij.CommonBundle; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.ResourceBundle; +public class GroovyDocBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "org.jetbrains.plugins.groovy.doc.GroovyDocBundle"; + private static final GroovyDocBundle INSTANCE = new GroovyDocBundle(); -public class GroovyDocBundle { + private GroovyDocBundle() { super(BUNDLE); } + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls - private static final String BUNDLE = "org.jetbrains.plugins.groovy.doc.GroovyDocBundle"; - - 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; + return INSTANCE.getMessage(key, params); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java index 1b4eb514a42b..b12aed23c064 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java @@ -16,36 +16,19 @@ package org.jetbrains.plugins.groovy.refactoring; -import org.jetbrains.annotations.NotNull; +import com.intellij.DynamicBundle; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.PropertyKey; -import java.util.ResourceBundle; -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; +public class GroovyRefactoringBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle"; + private static final GroovyRefactoringBundle INSTANCE = new GroovyRefactoringBundle(); -import com.intellij.CommonBundle; - -/** - * @author ilyas - */ -public class GroovyRefactoringBundle { + private GroovyRefactoringBundle() { super(BUNDLE); } + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls - private static final String BUNDLE = "org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle"; - - 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; + return INSTANCE.getMessage(key, params); } } \ No newline at end of file