mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
TextBlockBackwardMigrationInspection: replace backslash escape sequence with a regular backslash (IDEA-CR-52057)
GitOrigin-RevId: 5e154d3c8da28383191d83feff33857fa9ebe6c9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ddcc93dbcf
commit
a6b6061d04
@@ -227,13 +227,11 @@ public class PsiLiteralUtil {
|
||||
private static int parseBackSlash(@NotNull String str, int idx) {
|
||||
char c = str.charAt(idx);
|
||||
if (c != '\\') return -1;
|
||||
int nextIdx = parseHexBackSlash(str, idx);
|
||||
if (nextIdx > 0) return nextIdx;
|
||||
nextIdx = parseOctalBackSlash(str, idx);
|
||||
int nextIdx = parseEscapedBackSlash(str, idx);
|
||||
return nextIdx > 0 ? nextIdx : idx + 1;
|
||||
}
|
||||
|
||||
private static int parseHexBackSlash(@NotNull String str, int idx) {
|
||||
private static int parseEscapedBackSlash(@NotNull String str, int idx) {
|
||||
int next = idx + 1;
|
||||
if (next >= str.length() || str.charAt(next) != 'u') return -1;
|
||||
while (str.charAt(next) == 'u') {
|
||||
@@ -248,16 +246,4 @@ public class PsiLiteralUtil {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int parseOctalBackSlash(@NotNull String str, int idx) {
|
||||
int next = idx + 1;
|
||||
if (next + 2 >= str.length()) return -1;
|
||||
try {
|
||||
int code = Integer.parseInt(str.substring(next, next + 3), 8);
|
||||
if (code == '\\') return next + 3;
|
||||
}
|
||||
catch (NumberFormatException ignored) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
class TextBlockMigration {
|
||||
|
||||
void escapeSequence() {
|
||||
String oneLineTextBlock = "\"this is one \"line\"\n text block\\\"\n";
|
||||
String oneLineTextBlock = "\"this is one \"line\"\n text block\134\\\"\n";
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ class TextBlockMigration {
|
||||
|
||||
void escapeSequence() {
|
||||
String oneLineTextBlock = """
|
||||
\u005c"this is one "line"\n text <caret>block\134\"
|
||||
\u005c"this is one "line"\n text <caret>block\134\u005c\\"
|
||||
""";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user