mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix incorrect message bundle loading
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,31 +15,23 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.AbstractBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class JavaErrorMessages {
|
||||
public class JavaErrorMessages extends AbstractBundle {
|
||||
public static final JavaErrorMessages INSTANCE = new JavaErrorMessages();
|
||||
|
||||
@NonNls public static final String BUNDLE = "messages.JavaErrorMessages";
|
||||
|
||||
private JavaErrorMessages() {
|
||||
super(BUNDLE);
|
||||
}
|
||||
|
||||
public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
}
|
||||
|
||||
private static class ResourceBundleHolder {
|
||||
private static final ResourceBundle ourBundle = ResourceBundle.getBundle(BUNDLE);
|
||||
}
|
||||
|
||||
private static ResourceBundle getBundle() {
|
||||
return ResourceBundleHolder.ourBundle;
|
||||
return INSTANCE.getMessage(key, params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.lang.java.parser;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.AbstractBundle;
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -27,8 +27,6 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static com.intellij.lang.PsiBuilderUtil.expect;
|
||||
import static com.intellij.lang.java.parser.JavaParserUtil.*;
|
||||
|
||||
@@ -52,14 +50,17 @@ public class FileParser {
|
||||
}
|
||||
|
||||
public void parse(final PsiBuilder builder) {
|
||||
parseFile(builder, IMPORT_LIST_STOPPER_SET, JavaErrorMessages.BUNDLE, "expected.class.or.interface");
|
||||
parseFile(builder, IMPORT_LIST_STOPPER_SET, JavaErrorMessages.INSTANCE, "expected.class.or.interface");
|
||||
}
|
||||
|
||||
private static String error(@NotNull String bundle, @NotNull String errorMessageKey) {
|
||||
return CommonBundle.message(ResourceBundle.getBundle(bundle), errorMessageKey);
|
||||
private static String error(@NotNull AbstractBundle bundle, @NotNull String errorMessageKey) {
|
||||
return bundle.getMessage(errorMessageKey);
|
||||
}
|
||||
|
||||
public void parseFile(final PsiBuilder builder, final TokenSet importListStoppers, @NotNull String bundle, @NotNull String errorMessageKey) {
|
||||
public void parseFile(@NotNull final PsiBuilder builder,
|
||||
@NotNull final TokenSet importListStoppers,
|
||||
@NotNull final AbstractBundle bundle,
|
||||
@NotNull final String errorMessageKey) {
|
||||
parsePackageStatement(builder);
|
||||
|
||||
final Pair<PsiBuilder.Marker, Boolean> impListInfo = parseImportList(builder, importListStoppers);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij;
|
||||
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
@@ -27,33 +42,31 @@ import java.util.ResourceBundle;
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/1/11 2:37 PM
|
||||
*/
|
||||
public class AbstractBundle {
|
||||
|
||||
@NonNls
|
||||
private final String myPathToBundle;
|
||||
public abstract class AbstractBundle {
|
||||
@NonNls private final String myPathToBundle;
|
||||
|
||||
protected AbstractBundle(@NonNls @NotNull String pathToBundle) {
|
||||
myPathToBundle = pathToBundle;
|
||||
}
|
||||
|
||||
public String getMessage(String key, Object... params) {
|
||||
public String getMessage(@NotNull String key, Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
}
|
||||
|
||||
private ResourceBundle getBundle() {
|
||||
return getResourceBundle(myPathToBundle, getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private static FactoryMap<ClassLoader, ConcurrentHashMap<String, SoftReference<ResourceBundle>>> ourCache =
|
||||
new ConcurrentWeakFactoryMap<ClassLoader, ConcurrentHashMap<String, SoftReference<ResourceBundle>>>() {
|
||||
@Override
|
||||
protected ConcurrentHashMap<String, SoftReference<ResourceBundle>> create(ClassLoader key) {
|
||||
return new ConcurrentHashMap<String, SoftReference<ResourceBundle>>();
|
||||
}
|
||||
};
|
||||
|
||||
public static ResourceBundle getResourceBundle(String pathToBundle, ClassLoader loader) {
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
private static final FactoryMap<ClassLoader, ConcurrentHashMap<String, SoftReference<ResourceBundle>>> ourCache =
|
||||
new ConcurrentWeakFactoryMap<ClassLoader, ConcurrentHashMap<String, SoftReference<ResourceBundle>>>() {
|
||||
@Override
|
||||
protected ConcurrentHashMap<String, SoftReference<ResourceBundle>> create(ClassLoader key) {
|
||||
return new ConcurrentHashMap<String, SoftReference<ResourceBundle>>();
|
||||
}
|
||||
};
|
||||
|
||||
public static ResourceBundle getResourceBundle(@NotNull String pathToBundle, @NotNull ClassLoader loader) {
|
||||
ConcurrentHashMap<String, SoftReference<ResourceBundle>> map = ourCache.get(loader);
|
||||
SoftReference<ResourceBundle> reference = map.get(pathToBundle);
|
||||
ResourceBundle result = reference == null ? null : reference.get();
|
||||
|
||||
Reference in New Issue
Block a user