[java-inspections] EscapedSpaceInspection: proper unicode escape support

GitOrigin-RevId: 4595d28c6b09fa8ab5e1afe63cc34f95c5a17a86
This commit is contained in:
Tagir Valeev
2022-10-27 09:29:11 +00:00
committed by intellij-monorepo-bot
parent 7f445c6f03
commit c0f509d780
3 changed files with 20 additions and 2 deletions
@@ -0,0 +1,8 @@
// "Replace '\s' sequences with spaces" "true-preview"
class X {
void test(String str) {
if (str.matches("\uuu1234 +")) {
}
}
}
@@ -0,0 +1,8 @@
// "Replace '\s' sequences with spaces" "true-preview"
class X {
void test(String str) {
if (str.matches("\uuu1234<caret>\s+")) {
}
}
}
@@ -42,8 +42,10 @@ public class EscapedSpaceInspection extends AbstractBaseJavaLocalInspectionTool
if (pos == -1 || pos == text.length() - 1) break;
char next = text.charAt(pos + 1);
if (next == 'u') {
// unicode escape
pos += 6;
// unicode escape can contain several 'u', according to the spec
pos += 2;
while (pos < text.length() && text.charAt(pos) == 'u') pos++;
pos += 4;
continue;
}
pos += 2;