vcs/xml bundles

GitOrigin-RevId: 42df4c054ed96394ec9f0c9078f4d85b292fc147
This commit is contained in:
Sergey Ignatov
2019-12-19 13:32:33 +00:00
committed by intellij-monorepo-bot
parent c46a6e5cec
commit e5672a4631
11 changed files with 72 additions and 183 deletions
@@ -16,33 +16,21 @@
package com.intellij.usageView;
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 UsageViewBundle {
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 UsageViewBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "messages.UsageView";
private UsageViewBundle() {
}
private static final UsageViewBundle INSTANCE = new UsageViewBundle();
@SuppressWarnings({"AutoBoxing"})
public static String getUsagesString(int usagesCount, int filesCount) {
return " (" + message("occurence.info.usage", usagesCount, filesCount) + ")";
private UsageViewBundle() { super(BUNDLE); }
@NotNull
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
return INSTANCE.getMessage(key, params);
}
@SuppressWarnings({"AutoBoxing"})
@@ -54,13 +42,4 @@ public class UsageViewBundle {
public static String getReferencesString(int usagesCount, int filesCount) {
return " (" + message("occurence.info.reference", usagesCount, filesCount) + ")";
}
public static ResourceBundle getBundle() {
ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<>(bundle);
}
return bundle;
}
}
}
@@ -14,54 +14,25 @@
* limitations under the License.
*/
package git4idea.i18n;
/*
* 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.
*
* Author: Anatol Pomazu
*/
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 GitBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "git4idea.i18n.GitBundle";
private static final GitBundle INSTANCE = new GitBundle();
/**
* Git4Idea package I18N localization bundle helper
*/
public class GitBundle {
private GitBundle() { 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<ResourceBundle> ourBundle;
@NonNls
private static final String BUNDLE = "git4idea.i18n.GitBundle";
private GitBundle() {
@NotNull
public static String getString(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key) {
return message(key);
}
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);
}
}
}
@@ -12,34 +12,19 @@
// limitations under the License.
package org.zmlx.hg4idea;
import com.intellij.DynamicBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.PropertyKey;
import java.util.ResourceBundle;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
public class HgVcsMessages extends DynamicBundle {
@NonNls private static final String BUNDLE = "org.zmlx.hg4idea.HgVcsMessages";
private static final HgVcsMessages INSTANCE = new HgVcsMessages();
import com.intellij.CommonBundle;
private HgVcsMessages() { super(BUNDLE); }
public final class HgVcsMessages {
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull @Nullable 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<ResourceBundle> ourBundle;
private static final String BUNDLE = "org.zmlx.hg4idea.HgVcsMessages";
private HgVcsMessages() {
}
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;
}
}
}
@@ -15,37 +15,25 @@
*/
package org.jetbrains.idea.svn;
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 SvnBundle {
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 SvnBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "org.jetbrains.idea.svn.SvnBundle";
private SvnBundle() {
private static final SvnBundle INSTANCE = new SvnBundle();
private SvnBundle() { super(BUNDLE); }
@NotNull
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
return INSTANCE.getMessage(key, params);
}
public static String getString(@PropertyKey(resourceBundle = BUNDLE) String key) {
return getBundle().getString(key);
}
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 getString(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key) {
return message(key);
}
}
@@ -794,10 +794,10 @@ public class SvnFileSystemListener implements LocalFileOperationsHandler, Dispos
else {
final String singleFilePrompt;
if (addedVFiles.size() == 1 && addedVFiles.get(0).isDirectory()) {
singleFilePrompt = SvnBundle.getString("confirmation.text.add.dir");
singleFilePrompt = SvnBundle.message("confirmation.text.add.dir");
}
else {
singleFilePrompt = SvnBundle.getString("confirmation.text.add.file");
singleFilePrompt = SvnBundle.message("confirmation.text.add.file");
}
filesToProcess = vcsHelper.selectFilesToProcess(addedVFiles, SvnBundle.message("confirmation.title.add.multiple.files"),
null,
@@ -915,11 +915,11 @@ public class SvnFileSystemListener implements LocalFileOperationsHandler, Dispos
final String singleFilePrompt;
if (deletedFiles.size() == 1 && deletedFiles.get(0).getFirst().isDirectory()) {
singleFilePrompt = deletedFiles.get(0).getSecond().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN) ?
SvnBundle.getString("confirmation.text.delete.dir.17") :
SvnBundle.getString("confirmation.text.delete.dir");
SvnBundle.message("confirmation.text.delete.dir.17") :
SvnBundle.message("confirmation.text.delete.dir");
}
else {
singleFilePrompt = SvnBundle.getString("confirmation.text.delete.file");
singleFilePrompt = SvnBundle.message("confirmation.text.delete.file");
}
Collection<FilePath> files = vcsHelper
.selectFilePathsToProcess(map(deletedFiles, Functions.pairFirst()), SvnBundle.message("confirmation.title.delete.multiple.files"),
@@ -61,18 +61,18 @@ public class SvnChangeDiffViewerProvider implements ChangeDiffViewerWrapperProvi
throws DiffRequestProducerException {
try {
Change propertiesChange = getSvnChangeLayer(change);
if (propertiesChange == null) throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
if (propertiesChange == null) throw new DiffRequestProducerException(SvnBundle.message("diff.cant.get.properties.changes"));
ContentRevision bRevRaw = propertiesChange.getBeforeRevision();
ContentRevision aRevRaw = propertiesChange.getAfterRevision();
if (bRevRaw != null && !(bRevRaw instanceof PropertyRevision)) {
LOG.warn("Before change is not PropertyRevision");
throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
throw new DiffRequestProducerException(SvnBundle.message("diff.cant.get.properties.changes"));
}
if (aRevRaw != null && !(aRevRaw instanceof PropertyRevision)) {
LOG.warn("After change is not PropertyRevision");
throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
throw new DiffRequestProducerException(SvnBundle.message("diff.cant.get.properties.changes"));
}
PropertyRevision bRev = (PropertyRevision)bRevRaw;
@@ -84,7 +84,7 @@ public class SvnChangeDiffViewerProvider implements ChangeDiffViewerWrapperProvi
indicator.checkCanceled();
List<PropertyData> aContent = aRev != null ? aRev.getProperties() : null;
if (aRev == null && bRev == null) throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
if (aRev == null && bRev == null) throw new DiffRequestProducerException(SvnBundle.message("diff.cant.get.properties.changes"));
ContentRevision bRevMain = change.getBeforeRevision();
ContentRevision aRevMain = change.getAfterRevision();
@@ -16,36 +16,19 @@
package com.intellij.util.xml;
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 DomBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "messages.DomBundle";
private static final DomBundle INSTANCE = new DomBundle();
/**
* @author Dmitry Avdeev
*/
public class DomBundle {
private DomBundle() { super(BUNDLE); }
public static String message(@NotNull @PropertyKey(resourceBundle = "messages.DomBundle") 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<ResourceBundle> ourBundle;
@NonNls protected static final String PATH_TO_BUNDLE = "messages.DomBundle";
private DomBundle() {
}
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;
}
}
}
@@ -42,7 +42,7 @@ class CreateXmlElementIntentionAction implements IntentionAction {
private final String myDeclarationTagName;
CreateXmlElementIntentionAction(
@PropertyKey(resourceBundle = XmlBundle.PATH_TO_BUNDLE) String messageKey,
@PropertyKey(resourceBundle = XmlBundle.BUNDLE) String messageKey,
@NonNls @NotNull String declarationTagName,
TypeOrElementOrAttributeReference ref) {
@@ -37,7 +37,7 @@ public class SchemaReferenceQuickFixProvider extends UnresolvedReferenceQuickFix
);
}
else if (ref.getType() != null) {
@PropertyKey(resourceBundle = XmlBundle.PATH_TO_BUNDLE) String key = null;
@PropertyKey(resourceBundle = XmlBundle.BUNDLE) String key = null;
@NonNls String declarationTagName = null;
if (ref.getType() == TypeOrElementOrAttributeReference.ReferenceType.ElementReference) {
@@ -40,7 +40,7 @@ public class AddDtdDeclarationFix implements LocalQuickFix {
private final String myReference;
public AddDtdDeclarationFix(
@PropertyKey(resourceBundle = XmlBundle.PATH_TO_BUNDLE) String messageKey,
@PropertyKey(resourceBundle = XmlBundle.BUNDLE) String messageKey,
@NotNull String elementDeclarationName,
@NotNull PsiReference reference) {
myMessageKey = messageKey;
@@ -1,36 +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.xml;
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 XmlBundle extends DynamicBundle {
@NonNls public static final String BUNDLE = "messages.XmlBundle";
private static final XmlBundle INSTANCE = new XmlBundle();
private XmlBundle() { super(BUNDLE); }
/**
* @author lesya
*/
public class XmlBundle {
@NotNull
public static String message(@NotNull @PropertyKey(resourceBundle = PATH_TO_BUNDLE) String key, @NotNull Object... params) {
return CommonBundle.message(getBundle(), key, params);
public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
return INSTANCE.getMessage(key, params);
}
private static Reference<ResourceBundle> ourBundle;
@NonNls public static final String PATH_TO_BUNDLE = "messages.XmlBundle";
private XmlBundle() {
}
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;
}
}
}