From fdd69d0e2f4c36757371cf87ee26df4f3edf7e2e Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Thu, 19 Dec 2019 14:14:07 +0300 Subject: [PATCH] more bundles GitOrigin-RevId: 4758e170499a62ec2d5437c31166bef8d08d0175 --- .../analysis/AnalysisScopeBundle.java | 33 ++++------------ .../codeInsight/daemon/DaemonBundle.java | 33 ++++------------ .../codeInspection/CommonQuickFixBundle.java | 31 ++++----------- .../codeInspection/InspectionsBundle.java | 31 ++++----------- .../codeInsight/CodeInsightBundle.java | 33 ++++------------ .../intellij/openapi/editor/EditorBundle.java | 35 +++++------------ .../src/com/intellij/psi/PsiBundle.java | 34 ++++------------ .../src/com/intellij/dvcs/ui/DvcsBundle.java | 39 ++++++------------- .../com/intellij/openapi/diff/DiffBundle.java | 36 +++++------------ .../intellij/openapi/keymap/KeyMapBundle.java | 31 ++++----------- .../intellij/xdebugger/XDebuggerBundle.java | 32 ++++----------- 11 files changed, 94 insertions(+), 274 deletions(-) diff --git a/platform/analysis-api/src/com/intellij/analysis/AnalysisScopeBundle.java b/platform/analysis-api/src/com/intellij/analysis/AnalysisScopeBundle.java index 63769d3f562b..1700e13de3df 100644 --- a/platform/analysis-api/src/com/intellij/analysis/AnalysisScopeBundle.java +++ b/platform/analysis-api/src/com/intellij/analysis/AnalysisScopeBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.analysis; -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 AnalysisScopeBundle { - private static Reference ourBundle; - +public class AnalysisScopeBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.AnalysisScopeBundle"; + private static final AnalysisScopeBundle INSTANCE = new AnalysisScopeBundle(); - private AnalysisScopeBundle() { - } + private AnalysisScopeBundle() { super(BUNDLE); } - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE)String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(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; - } -} +} \ No newline at end of file diff --git a/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java index 7507143349e1..19ce35acce04 100644 --- a/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.codeInsight.daemon; -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 DaemonBundle { - private static Reference ourBundle; - +public class DaemonBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.DaemonBundle"; + private static final DaemonBundle INSTANCE = new DaemonBundle(); - private DaemonBundle() { - } + private DaemonBundle() { super(BUNDLE); } - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE)String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(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; - } -} +} \ No newline at end of file diff --git a/platform/analysis-api/src/com/intellij/codeInspection/CommonQuickFixBundle.java b/platform/analysis-api/src/com/intellij/codeInspection/CommonQuickFixBundle.java index f0e97429aa6f..c9334c6d4167 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/CommonQuickFixBundle.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/CommonQuickFixBundle.java @@ -1,34 +1,19 @@ // Copyright 2000-2018 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.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 CommonQuickFixBundle extends DynamicBundle { + @NonNls public static final String BUNDLE = "messages.CommonQuickFixBundle"; + private static final CommonQuickFixBundle INSTANCE = new CommonQuickFixBundle(); -/** - * This bundle contains messages for quick-fixes and intention actions which can be reused across languages. - */ -public class CommonQuickFixBundle { - private static Reference ourBundle; - - public static final String BUNDLE = "messages.CommonQuickFixBundle"; - - private CommonQuickFixBundle() { } + private CommonQuickFixBundle() { super(BUNDLE); } + @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; + return INSTANCE.getMessage(key, params); } } \ No newline at end of file diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionsBundle.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionsBundle.java index f71165c17dd9..e1faf6cfeb62 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionsBundle.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionsBundle.java @@ -15,34 +15,19 @@ */ package com.intellij.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 InspectionsBundle extends DynamicBundle { + @NonNls public static final String BUNDLE = "messages.InspectionsBundle"; + private static final InspectionsBundle INSTANCE = new InspectionsBundle(); -/** - * @author max - */ -public class InspectionsBundle { - private static Reference ourBundle; - - public static final String BUNDLE = "messages.InspectionsBundle"; - - private InspectionsBundle() { } + private InspectionsBundle() { super(BUNDLE); } + @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; + return INSTANCE.getMessage(key, params); } } \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/codeInsight/CodeInsightBundle.java b/platform/core-api/src/com/intellij/codeInsight/CodeInsightBundle.java index bcca042c6b2a..abc6df4ae47f 100644 --- a/platform/core-api/src/com/intellij/codeInsight/CodeInsightBundle.java +++ b/platform/core-api/src/com/intellij/codeInsight/CodeInsightBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.codeInsight; -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 CodeInsightBundle { - - 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 CodeInsightBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.CodeInsightBundle"; + private static final CodeInsightBundle INSTANCE = new CodeInsightBundle(); - private CodeInsightBundle() { - } + private CodeInsightBundle() { 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/platform/core-api/src/com/intellij/openapi/editor/EditorBundle.java b/platform/core-api/src/com/intellij/openapi/editor/EditorBundle.java index 66848363c1cd..bee5bf09e6a0 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/EditorBundle.java +++ b/platform/core-api/src/com/intellij/openapi/editor/EditorBundle.java @@ -15,36 +15,19 @@ */ package com.intellij.openapi.editor; -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 EditorBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "messages.EditorBundle"; + private static final EditorBundle INSTANCE = new EditorBundle(); -/** - * @author lesya - */ -public class EditorBundle { + private EditorBundle() { super(BUNDLE); } - public static String message(@NotNull @PropertyKey(resourceBundle = PATH_TO_BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } - - private static Reference ourBundle; - @NonNls protected static final String PATH_TO_BUNDLE = "messages.EditorBundle"; - - private EditorBundle() { - } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; - } -} +} \ No newline at end of file diff --git a/platform/core-api/src/com/intellij/psi/PsiBundle.java b/platform/core-api/src/com/intellij/psi/PsiBundle.java index 011a1003d2f8..5198c94156aa 100644 --- a/platform/core-api/src/com/intellij/psi/PsiBundle.java +++ b/platform/core-api/src/com/intellij/psi/PsiBundle.java @@ -15,42 +15,24 @@ */ package com.intellij.psi; -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 PsiBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "messages.PsiBundle"; + private static final PsiBundle INSTANCE = new PsiBundle(); -/** - * @author max - */ -public class PsiBundle { + private PsiBundle() { 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.PsiBundle"; - - private PsiBundle() { - } - - 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 visibilityPresentation(@NotNull String modifier) { return message(modifier + ".visibility.presentation"); } -} +} \ No newline at end of file diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.java b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.java index e3201e7e7a2e..e2ad745bb281 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.java @@ -15,41 +15,24 @@ */ package com.intellij.dvcs.ui; -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 DvcsBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "com.intellij.dvcs.ui.DvcsBundle"; + private static final DvcsBundle INSTANCE = new DvcsBundle(); -/** - * @author Nadya Zabrodina - */ -public class DvcsBundle { + private DvcsBundle() { 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 = "com.intellij.dvcs.ui.DvcsBundle"; - - private DvcsBundle() { - } - - 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 getString(@PropertyKey(resourceBundle = BUNDLE) final String key) { - return getBundle().getString(key); + + @NotNull + public static String getString(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key) { + return message(key); } } diff --git a/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java b/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java index ccbf7db8074c..8244a691dac5 100644 --- a/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java +++ b/platform/platform-api/src/com/intellij/openapi/diff/DiffBundle.java @@ -15,36 +15,20 @@ */ package com.intellij.openapi.diff; -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 DiffBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "messages.DiffBundle"; -/** - * @author lesya - */ -public class DiffBundle { + private static final DiffBundle INSTANCE = new DiffBundle(); - public static String message(@NotNull @PropertyKey(resourceBundle = PATH_TO_BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); + private DiffBundle() { super(BUNDLE); } + + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); } - - private static Reference ourBundle; - @NonNls protected static final String PATH_TO_BUNDLE = "messages.DiffBundle"; - - private DiffBundle() { - } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE); - ourBundle = new SoftReference<>(bundle); - } - return bundle; - } -} +} \ No newline at end of file diff --git a/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java b/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java index 5b41d31d03ae..3e40b65fd55f 100644 --- a/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java +++ b/platform/platform-api/src/com/intellij/openapi/keymap/KeyMapBundle.java @@ -16,34 +16,19 @@ package com.intellij.openapi.keymap; -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 KeyMapBundle extends DynamicBundle { + @NonNls private static final String BUNDLE = "messages.KeyMapBundle"; + private static final KeyMapBundle INSTANCE = new KeyMapBundle(); -public class KeyMapBundle { + private KeyMapBundle() { super(BUNDLE); } - public static String message(@NotNull @PropertyKey(resourceBundle = "messages.KeyMapBundle") String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference ourBundle; - @NonNls - protected static final String PATH_TO_BUNDLE = "messages.KeyMapBundle"; - - private KeyMapBundle() { - } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(PATH_TO_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); } } diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerBundle.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerBundle.java index 96df838b3b6c..c3e817064e5c 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerBundle.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebuggerBundle.java @@ -16,35 +16,19 @@ package com.intellij.xdebugger; -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 nik - */ -public class XDebuggerBundle { - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - +public class XDebuggerBundle extends DynamicBundle { @NonNls private static final String BUNDLE = "messages.XDebuggerBundle"; - private static Reference ourBundle; + private static final XDebuggerBundle INSTANCE = new XDebuggerBundle(); - private XDebuggerBundle() { - } + private XDebuggerBundle() { 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