From d4e38966530c99e89b082a3ef75e6dde9f02edfe Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Thu, 1 Nov 2012 04:25:49 +0400 Subject: [PATCH] fix tests & double formatting --- .../src/com/intellij/codeInspection/ProblemsHolder.java | 3 ++- platform/util-rt/src/com/intellij/BundleBase.java | 4 ++++ .../codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java b/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java index 8ce77f2eef98..2ad696ce1e9f 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java +++ b/platform/lang-api/src/com/intellij/codeInspection/ProblemsHolder.java @@ -16,6 +16,7 @@ package com.intellij.codeInspection; +import com.intellij.BundleBase; import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; import com.intellij.lang.injection.InjectedLanguageManager; @@ -143,7 +144,7 @@ public class ProblemsHolder { String message; if (reference instanceof EmptyResolveMessageProvider) { String pattern = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern(); - message = pattern.contains("{0}") ? MessageFormat.format(pattern, reference.getCanonicalText()) : pattern; + message = BundleBase.format(pattern, reference.getCanonicalText()); // avoid double formatting } else { message = CodeInsightBundle.message("error.cannot.resolve.default.message", reference.getCanonicalText()); diff --git a/platform/util-rt/src/com/intellij/BundleBase.java b/platform/util-rt/src/com/intellij/BundleBase.java index 065c53f1690a..8b230fe0e160 100644 --- a/platform/util-rt/src/com/intellij/BundleBase.java +++ b/platform/util-rt/src/com/intellij/BundleBase.java @@ -55,6 +55,10 @@ public abstract class BundleBase { value = replaceMnemonicAmpersand(value); + return format(value, params); + } + + public static String format(String value, Object... params) { if (params.length > 0 && value.indexOf('{') >= 0) { return MessageFormat.format(value, params); } diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java index 6786de1c3861..96b111aa10db 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java @@ -15,6 +15,7 @@ */ package com.intellij.codeInsight.daemon.impl.analysis; +import com.intellij.BundleBase; import com.intellij.codeInsight.daemon.*; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; @@ -58,7 +59,6 @@ import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.text.MessageFormat; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; @@ -653,7 +653,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV String description; try { - description = MessageFormat.format(message, reference.getCanonicalText()); + description = BundleBase.format(message, reference.getCanonicalText()); // avoid double formatting } catch (IllegalArgumentException ex) { // unresolvedMessage provided by third-party reference contains wrong format string (e.g. {}), tolerate it