diff --git a/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index a312eeed7b4..1c80045e5b6 100644 --- a/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -36,9 +36,11 @@ public class StringUtils { public static final int DOLLAR_SLASHY = 2; public static String replaceEscapes(String text, int slashyType) { - if (slashyType == SLASHY || slashyType == DOLLAR_SLASHY) { - text = StringUtils.replaceHexEscapes(text); - text = StringUtils.replaceLineEscape(text); + if (slashyType == NONE_SLASHY) { + text = replaceEscapes(text); + } else if (slashyType == SLASHY || slashyType == DOLLAR_SLASHY) { + text = replaceHexEscapes(text); + text = replaceLineEscape(text); if (slashyType == SLASHY) { text = replace(text,"\\/", "/"); @@ -46,9 +48,7 @@ public static String replaceEscapes(String text, int slashyType) { text = replace(text,"$/", "/"); text = replace(text,"$$", "$"); } - } else if (slashyType == NONE_SLASHY) { - text = StringUtils.replaceEscapes(text); - } else { + } else { throw new IllegalArgumentException("Invalid slashyType: " + slashyType); } @@ -160,8 +160,8 @@ public static boolean isEmpty(final CharSequence cs) { private static String replaceEscapes(String text) { if (!text.contains(BACKSLASH)) return text; text = replace(text,"\\$", "$"); - text = StringUtils.replaceLineEscape(text); - return StringUtils.replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text))); + text = replaceLineEscape(text); + return replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text))); } private static String replaceLineEscape(String text) {