From 26a0af9d47b6b9fe5ea89bdda7d84695ab64db1b Mon Sep 17 00:00:00 2001 From: Louis Vignier Date: Mon, 3 Aug 2020 16:01:55 +0200 Subject: [PATCH] i18n: extract SSR related strings to SSRBundle GitOrigin-RevId: f8a3ba74b3667390365c16bf50a67b15f3962a0c --- .../structuralsearch/JavaPredefinedConfigurations.java | 4 ++-- .../impl/matcher/compiler/JavaCompilingVisitor.java | 5 +++-- .../source/com/intellij/structuralsearch/Matcher.java | 4 ++-- .../impl/matcher/compiler/PatternCompiler.java | 2 +- .../structuralsearch/source/messages/SSRBundle.properties | 7 +++++++ 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java index eaa5fd5b83c9..363a733fd052 100644 --- a/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java +++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java @@ -52,7 +52,7 @@ final class JavaPredefinedConfigurations { getOperatorType()), createSearchTemplateInfo(SSRBundle.message("predefined.configuration.logging.without.if"), "[!within( statement in if )]LOG.debug('_Argument*);", getOperatorType()), - createSearchTemplateInfo("statement in if", "if('_condition) { 'statement*; }", getOperatorType()), + createSearchTemplateInfo(SSRBundle.message("predefined.configuration.statement.in.if"), "if('_condition) { 'statement*; }", getOperatorType()), createSearchTemplateInfo(SSRBundle.message("predefined.configuration.assert.without.description"), "assert '_condition : '_description{0};", getOperatorType()), @@ -374,7 +374,7 @@ final class JavaPredefinedConfigurations { //createSearchTemplateInfo("symbols used","'_:[ref('Symbol)] ", INTERESTING_TYPE), //createSearchTemplateInfo("types used","'_:[ref('Type)] '_;", INTERESTING_TYPE), - createSearchTemplateInfo("xml attribute references java class", "<'_tag 'attribute=\"'_value:[ref( classes, interfaces & enums )]\"/>", SSRBundle.message("xml_html.category"), StdFileTypes.XML), + createSearchTemplateInfo(SSRBundle.message("predefined.configuration.xml.attribute.referencing.java.class"), "<'_tag 'attribute=\"'_value:[ref( classes, interfaces & enums )]\"/>", SSRBundle.message("xml_html.category"), StdFileTypes.XML), }; } diff --git a/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/compiler/JavaCompilingVisitor.java b/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/compiler/JavaCompilingVisitor.java index 9391e78e0101..b44289540d81 100644 --- a/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/compiler/JavaCompilingVisitor.java +++ b/java/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/compiler/JavaCompilingVisitor.java @@ -14,6 +14,7 @@ import com.intellij.psi.search.searches.ClassInheritorsSearch; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.structuralsearch.MalformedPatternException; +import com.intellij.structuralsearch.SSRBundle; import com.intellij.structuralsearch.StructuralSearchUtil; import com.intellij.structuralsearch.impl.matcher.CompiledPattern; import com.intellij.structuralsearch.impl.matcher.JavaCompiledPattern; @@ -237,7 +238,7 @@ public class JavaCompilingVisitor extends JavaRecursiveElementWalkingVisitor { if (PsiType.CHAR.equals(expression.getType()) && (handler instanceof LiteralWithSubstitutionHandler || handler == null && expression.getValue() == null)) { - throw new MalformedPatternException("Bad character literal"); + throw new MalformedPatternException(SSRBundle.message("error.bad.character.literal")); } if (handler != null) { expression.putUserData(CompiledPattern.HANDLER_KEY, handler); @@ -245,7 +246,7 @@ public class JavaCompilingVisitor extends JavaRecursiveElementWalkingVisitor { } else { if (!PsiType.NULL.equals(expression.getType()) && expression.getValue() == null) { - throw new MalformedPatternException("Bad literal"); + throw new MalformedPatternException(SSRBundle.message("error.bad.literal")); } } super.visitLiteralExpression(expression); diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java b/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java index 8122f0cdee5e..a612f3d46e06 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/Matcher.java @@ -88,12 +88,12 @@ public class Matcher { else { final Set set = ourRecursionGuard.get(); if (!set.add(constraint)) { - throw new MalformedPatternException("Pattern recursively references itself"); + throw new MalformedPatternException(SSRBundle.message("error.pattern.recursively.references.itself")); } try { final Configuration configuration = ConfigurationManager.getInstance(project).findConfigurationByName(constraint); if (configuration == null) { - throw new MalformedPatternException("Configuration '" + constraint + "' not found"); + throw new MalformedPatternException(SSRBundle.message("error.configuration.0.not.found", constraint)); } return new Matcher(project, configuration.getMatchOptions()); } finally { diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java index 8684bfc58f57..7efff12b197d 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java @@ -588,7 +588,7 @@ public final class PatternCompiler { final String problem = ScriptSupport.checkValidScript(script, matchOptions); if (problem != null) { if (checkForErrors) { - throw new MalformedPatternException("Script constraint for " + constraint.getName() + " has problem " + problem); + throw new MalformedPatternException(SSRBundle.message("error.script.constraint.for.0.has.problem.1", constraint.getName(), problem)); } else { return; diff --git a/platform/structuralsearch/source/messages/SSRBundle.properties b/platform/structuralsearch/source/messages/SSRBundle.properties index b32f8e261a56..d0c06c0776f8 100644 --- a/platform/structuralsearch/source/messages/SSRBundle.properties +++ b/platform/structuralsearch/source/messages/SSRBundle.properties @@ -230,6 +230,8 @@ predefined.configuration.sample.method.invokation.with.constant.argument=sample predefined.configuration.interfaces.having.no.descendants=interface that is not implemented or extended predefined.configuration.enums=enums predefined.configuration.comments.containing.word=comments containing a given word +predefined.configuration.xml.attribute.referencing.java.class=xml attribute referencing java class +predefined.configuration.statement.in.if=statement in if # edit variable constraint dialog options invalid.regular.expression=Invalid regular expression\: {0} @@ -276,6 +278,11 @@ invalid.modifier.type=Invalid modifier type {0} error.argument.expected=Argument expected on ''{0}'' constraint error.cannot.invert=Cannot invert ''{0}'' constraint error.only.applicable.to.complete.match=Constraint ''{0}'' is only applicable to Complete Match +error.bad.character.literal=Bad character literal +error.bad.literal=Bad literal +error.pattern.recursively.references.itself=Pattern recursively references itself +error.configuration.0.not.found=Configuration ''{0}'' not found +error.script.constraint.for.0.has.problem.1=Script constraint for {0} has problem {1} SSRInspection.replace.with=Replace with ''{0}'' SSRInspection.family.name=Replace Structurally