diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerBundle.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerBundle.java index 8bf26a6427c9..c797525d6c0a 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerBundle.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerBundle.java @@ -15,42 +15,19 @@ */ package com.intellij.openapi.compiler; -import com.intellij.CommonBundle; -import com.intellij.openapi.projectRoots.Sdk; +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 CompilerBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "messages.CompilerBundle"; + private static final CompilerBundle INSTANCE = new CompilerBundle(); -/** - * @author Eugene Zhuravlev - */ -public class CompilerBundle { + private CompilerBundle() { super(BUNDLE); } @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + return INSTANCE.getMessage(key, params); } - - private static Reference ourBundle; - @NonNls private static final String BUNDLE = "messages.CompilerBundle"; - - private CompilerBundle() { - } - - public static String jdkHomeNotFoundMessage(final Sdk jdk) { - return message("javac.error.jdk.home.missing", jdk.getName(), jdk.getHomePath()); - } - - 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; - } -} +} \ No newline at end of file diff --git a/java/debugger/openapi/src/com/intellij/debugger/DebuggerBundle.java b/java/debugger/openapi/src/com/intellij/debugger/DebuggerBundle.java index 8475d15bae07..7ddcb0afe009 100644 --- a/java/debugger/openapi/src/com/intellij/debugger/DebuggerBundle.java +++ b/java/debugger/openapi/src/com/intellij/debugger/DebuggerBundle.java @@ -15,27 +15,22 @@ */ package com.intellij.debugger; -import com.intellij.CommonBundle; +import com.intellij.DynamicBundle; import com.intellij.execution.configurations.RemoteConnection; import com.intellij.openapi.util.text.StringUtil; 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 DebuggerBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class DebuggerBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.DebuggerBundle"; + private static final DebuggerBundle INSTANCE = new DebuggerBundle(); - private DebuggerBundle() { + private DebuggerBundle() { super(BUNDLE); } + + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } public static String getAddressDisplayName(final RemoteConnection connection) { @@ -46,13 +41,4 @@ public class DebuggerBundle { public static String getTransportName(final RemoteConnection connection) { return connection.isUseSockets() ? message("transport.name.socket") : message("transport.name.shared.memory"); } - - 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; - } -} +} \ No newline at end of file diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/QuickFixBundle.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/QuickFixBundle.java index ca10bbaf04bc..96452c340e9b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/QuickFixBundle.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/QuickFixBundle.java @@ -1,37 +1,19 @@ // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.daemon; -import com.intellij.CommonBundle; -import org.jetbrains.annotations.Nls; +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 QuickFixBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "messages.QuickFixBundle"; + private static final QuickFixBundle INSTANCE = new QuickFixBundle(); -/** - * @author max - */ -public class QuickFixBundle { - private static Reference ourBundle; + private QuickFixBundle() { super(BUNDLE); } - private static final String BUNDLE = "messages.QuickFixBundle"; - - private QuickFixBundle() { } - - @Nls @NotNull - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE)String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - 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; + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/CompletionBundle.java b/java/java-impl/src/com/intellij/codeInsight/completion/CompletionBundle.java index 6171523f66cf..2a5878d37fd6 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/CompletionBundle.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/CompletionBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.codeInsight.completion; -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; - -/** - * @author max - */ -public class CompletionBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class CompletionBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.CompletionBundle"; + private static final CompletionBundle INSTANCE = new CompletionBundle(); - private CompletionBundle() { - } + private CompletionBundle() { super(BUNDLE); } - 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; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocBundle.java b/java/java-impl/src/com/intellij/javadoc/JavadocBundle.java index fdfd406d0978..290da4eb176a 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocBundle.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.javadoc; -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; - -/** - * @author yole - */ -public class JavadocBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class JavadocBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.JavadocBundle"; + private static final JavadocBundle INSTANCE = new JavadocBundle(); - private JavadocBundle() { - } + private JavadocBundle() { super(BUNDLE); } - 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; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/java/java-psi-api/src/com/intellij/core/JavaCoreBundle.java b/java/java-psi-api/src/com/intellij/core/JavaCoreBundle.java index d320430dcae4..0a29083eac75 100644 --- a/java/java-psi-api/src/com/intellij/core/JavaCoreBundle.java +++ b/java/java-psi-api/src/com/intellij/core/JavaCoreBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.core; -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; - -/** - * @author max - */ -public class JavaCoreBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class JavaCoreBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.JavaCoreBundle"; + private static final JavaCoreBundle INSTANCE = new JavaCoreBundle(); - private JavaCoreBundle() { - } + private JavaCoreBundle() { super(BUNDLE); } - 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; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.java index fc46c59a8e9a..6634619cac56 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.java @@ -1,38 +1,19 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.siyeh; -import com.intellij.CommonBundle; -import org.jetbrains.annotations.Contract; +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; - -/** - * @author max - */ -public class InspectionGadgetsBundle { - @NotNull - @Contract(pure = true) - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class InspectionGadgetsBundle extends DynamicBundle { @NonNls public static final String BUNDLE = "com.siyeh.InspectionGadgetsBundle"; + private static final InspectionGadgetsBundle INSTANCE = new InspectionGadgetsBundle(); - private InspectionGadgetsBundle() { - } + private InspectionGadgetsBundle() { super(BUNDLE); } - 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; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java index 0875e7658c65..6b4c7d677660 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java @@ -16,36 +16,18 @@ package org.jetbrains.plugins.groovy; -import com.intellij.CommonBundle; -import org.jetbrains.annotations.NonNls; +import com.intellij.DynamicBundle; 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 GroovyBundle extends DynamicBundle { + public static final String BUNDLE = "org.jetbrains.plugins.groovy.GroovyBundle"; + private static final GroovyBundle INSTANCE = new GroovyBundle(); -/** - * @author ilyas - */ -public class GroovyBundle { + private GroovyBundle() { super(BUNDLE); } @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + return INSTANCE.getMessage(key, params); } - - private static Reference ourBundle; - @NonNls - public static final String BUNDLE = "org.jetbrains.plugins.groovy.GroovyBundle"; - - 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; - } -} +} \ No newline at end of file diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java index bac171a6eb57..4827a886cb58 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java @@ -15,35 +15,19 @@ */ package org.jetbrains.plugins.groovy.codeInspection; -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 GroovyInspectionBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle"; + private static final GroovyInspectionBundle INSTANCE = new GroovyInspectionBundle(); -/** - * @author ilyas - */ -public class GroovyInspectionBundle { + private GroovyInspectionBundle() { 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.codeInspection.GroovyInspectionBundle"; - - 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 diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java index eda2fb684faa..6fd18e24816f 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java @@ -16,35 +16,19 @@ package org.jetbrains.plugins.groovy.intentions; -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 GroovyIntentionsBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle"; + private static final GroovyIntentionsBundle INSTANCE = new GroovyIntentionsBundle(); -/** - * @author ilyas - */ -public class GroovyIntentionsBundle { + private GroovyIntentionsBundle() { super(BUNDLE); } + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + return INSTANCE.getMessage(key, params); } - - private static Reference ourBundle; - @NonNls - private static final String BUNDLE = "org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle"; - - 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; - } -} +} \ No newline at end of file diff --git a/plugins/ui-designer/src/com/intellij/uiDesigner/UIDesignerBundle.java b/plugins/ui-designer/src/com/intellij/uiDesigner/UIDesignerBundle.java index 334b22b57724..20c1a219cb9e 100644 --- a/plugins/ui-designer/src/com/intellij/uiDesigner/UIDesignerBundle.java +++ b/plugins/ui-designer/src/com/intellij/uiDesigner/UIDesignerBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.uiDesigner; -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; - -/** - * @author yole - */ -public class UIDesignerBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; +public class UIDesignerBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.UIDesignerBundle"; + private static final UIDesignerBundle INSTANCE = new UIDesignerBundle(); - private UIDesignerBundle() { - } + private UIDesignerBundle() { super(BUNDLE); } - 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; + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } -} +} \ No newline at end of file