more bundles

GitOrigin-RevId: 65962fd2f2158e1aaeed619497ec0545bbf8d2e8
This commit is contained in:
Sergey Ignatov
2019-12-19 23:05:54 +03:00
committed by intellij-monorepo-bot
parent 0e499010b2
commit 562ace00c2
2 changed files with 15 additions and 58 deletions

View File

@@ -15,36 +15,19 @@
*/
package com.intellij.designer;
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 DesignerBundle {
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
return CommonBundle.message(getBundle(), key, params);
}
private static Reference<ResourceBundle> ourBundle;
public class DesignerBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "messages.DesignerBundle";
private static final DesignerBundle INSTANCE = new DesignerBundle();
private DesignerBundle() {
}
private DesignerBundle() { 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);
}
}

View File

@@ -1,44 +1,18 @@
package org.jetbrains.yaml;
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.PropertyKey;
import java.lang.ref.Reference;
import java.util.ResourceBundle;
public class YAMLBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "messages.YAMLBundle";
private static final YAMLBundle INSTANCE = new YAMLBundle();
private YAMLBundle() { super(BUNDLE); }
/**
* @author oleg
*/
public class YAMLBundle {
@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<ResourceBundle> ourBundle;
@NonNls
private static final String BUNDLE = "messages.YAMLBundle";
private YAMLBundle() {
}
/*
* This method added for jruby access
*/
@NotNull
public static String message(@PropertyKey(resourceBundle = BUNDLE) String key) {
return CommonBundle.message(getBundle(), key);
}
private static ResourceBundle getBundle() {
ResourceBundle bundle = SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<>(bundle);
}
return bundle;
}
}
}