IDEA-133955 ("Unnecessary unicode escape sequence" is triggered for surrogate characters.)

This commit is contained in:
Bas Leijdekkers
2014-12-05 23:22:13 +01:00
parent 40097dd996
commit fa3b145b53
2 changed files with 9 additions and 6 deletions
@@ -156,13 +156,14 @@ public class UnnecessaryUnicodeEscapeInspection extends BaseInspection {
charBuffer.clear();
charBuffer.put(d).rewind();
final CoderResult coderResult = encoder.encode(charBuffer, byteBuffer, true);
if (!coderResult.isUnmappable()) {
final PsiElement element = file.findElementAt(i);
if (element != null && isSuppressedFor(element)) {
return;
}
registerErrorAtOffset(file, i, escapeEnd - i, Character.valueOf(d));
if (coderResult.isError()) {
continue;
}
final PsiElement element = file.findElementAt(i);
if (element != null && isSuppressedFor(element)) {
return;
}
registerErrorAtOffset(file, i, escapeEnd - i, Character.valueOf(d));
}
}
}
@@ -3,6 +3,8 @@ package com.siyeh.igtest.internationalization.unnecessary_unicode_escape;
class UnnecessaryUnicodeEscape {
// <warning descr="Unicode escape sequence '\uuuuuu0061' can be replaced with 'a'">\uuuuuu0061</warning><warning descr="Unicode escape sequence '\u0062' can be replaced with 'b'">\u0062</warning>
// control char & not representable char: \u0010 \u00e4
char[] surrogates = new char[]{'\ud800','\udc00'};
}
@SuppressWarnings("UnnecessaryUnicodeEscape")
class Suppress {