mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: relax replacement template check
GitOrigin-RevId: 419923fbe5c761e856e208e8e8610ff22199136d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
53ec26e0de
commit
86c22aeb2f
+2
-5
@@ -566,11 +566,8 @@ public final class JavaStructuralSearchProfile extends StructuralSearchProfile {
|
||||
final boolean searchIsExpression = targetNode != null
|
||||
? getPresentableElement(targetNode) instanceof PsiExpression
|
||||
: isExpressionTemplate(compiledPattern.getVariableNodes(Configuration.CONTEXT_VAR_NAME));
|
||||
if (searchIsExpression != replaceIsExpression) {
|
||||
throw new UnsupportedPatternException(
|
||||
searchIsExpression ? SSRBundle.message("replacement.template.is.not.expression.error.message") :
|
||||
SSRBundle.message("search.template.is.not.expression.error.message")
|
||||
);
|
||||
if (searchIsExpression && !replaceIsExpression) {
|
||||
throw new UnsupportedPatternException(SSRBundle.message("replacement.template.is.not.expression.error.message"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,9 +245,9 @@ script.tooltip.message=script
|
||||
reference.target.tooltip.message=reference{0,choice,0#=|1#\u2260}{1}
|
||||
replacement.variable.is.not.defined.message=Unknown search variable ''{0}'' or replacement variable ''{0}'' has no script
|
||||
replacement.variable.is.not.valid=Replacement variable ''{0}'' has script code problem: {1}
|
||||
replacement.template.is.not.expression.error.message=An expression can not be replaced with a non-expression
|
||||
replacement.template.is.not.expression.error.message=An expression cannot be replaced with a non-expression
|
||||
replacement.not.supported.for.filetype=Replacement is not supported for {0} file type
|
||||
search.template.is.not.expression.error.message=A non-expression can not be replaced with an expression
|
||||
search.template.is.not.expression.error.message=A non-expression cannot be replaced with an expression
|
||||
|
||||
modify.editor.content.command.name=Modify Editor Content
|
||||
option.is.not.recognized.error.message=Constraint ''{0}'' not recognized
|
||||
|
||||
+8
-7
@@ -1730,13 +1730,6 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase {
|
||||
String s5 = "a=a;";
|
||||
String s6 = "a=a";
|
||||
|
||||
try {
|
||||
replace(s4, s5, s6);
|
||||
fail("Undefined no ; in replace");
|
||||
}
|
||||
catch (UnsupportedPatternException ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
replace(s4, s6, s5);
|
||||
fail("Undefined no ; in search");
|
||||
@@ -2465,6 +2458,14 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase {
|
||||
assertEquals("Should replace unmatched annotation parameters when matching just annotation",
|
||||
expected1d, replace(in1, "@SuppressWarnings", "@ SuppressWarnings"));
|
||||
|
||||
String what1 = "@SuppressWarnings(\"'value\")";
|
||||
String by = "$lower_case$";
|
||||
final ReplacementVariableDefinition variable = options.addNewVariableDefinition("lower_case");
|
||||
variable.setScriptCodeConstraint("value.getText().toLowerCase()");
|
||||
final String expected1e = "@SuppressWarnings(\"all\")\n" +
|
||||
"public class A {}";
|
||||
assertEquals(expected1e, replace(in1, what1, by));
|
||||
|
||||
|
||||
final String in2 = """
|
||||
class X {
|
||||
|
||||
Reference in New Issue
Block a user