mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: don't report (more) invisible characters as unnecessary escapes (IDEA-169813)
This commit is contained in:
+15
-2
@@ -37,7 +37,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
@@ -146,7 +149,17 @@ public class UnnecessaryUnicodeEscapeInspection extends BaseInspection {
|
||||
StringUtil.isHexDigit(text.charAt(nextChar + 3))) {
|
||||
final int escapeEnd = nextChar + 4;
|
||||
final char d = (char)Integer.parseInt(text.substring(nextChar, escapeEnd), 16);
|
||||
if (Character.isISOControl(d)) {
|
||||
final int type = Character.getType(d);
|
||||
if (type == Character.CONTROL ||
|
||||
type == Character.FORMAT ||
|
||||
type == Character.PRIVATE_USE ||
|
||||
type == Character.SURROGATE ||
|
||||
type == Character.UNASSIGNED ||
|
||||
type == Character.LINE_SEPARATOR ||
|
||||
type == Character.PARAGRAPH_SEPARATOR) {
|
||||
continue;
|
||||
}
|
||||
if (type == Character.SPACE_SEPARATOR && d != ' ') {
|
||||
continue;
|
||||
}
|
||||
byteBuffer.clear();
|
||||
|
||||
+3
@@ -5,6 +5,9 @@ class UnnecessaryUnicodeEscape {
|
||||
// control char & not representable char: \u0010 \u00e4
|
||||
|
||||
char[] surrogates = new char[]{'\ud800','\udc00'};
|
||||
|
||||
String t = "<warning descr="Unicode escape sequence '\u0020' can be replaced with ' '">\u0020</warning>";
|
||||
String u = "\u200B\u200E\u00A0\u200F";
|
||||
}
|
||||
@SuppressWarnings("UnnecessaryUnicodeEscape")
|
||||
class Suppress {
|
||||
|
||||
Reference in New Issue
Block a user