java: don't warn on Combining Diacritical Marks and other combining characters (IDEA-350383)

in "Unnecessary Unicode escape sequence" inspection

GitOrigin-RevId: 0e76b6680df5ca6001d6ff249bc8246c11dd78a6
This commit is contained in:
Bas Leijdekkers
2025-04-12 16:28:13 +00:00
committed by intellij-monorepo-bot
parent 602cb1bafd
commit e3ce040c5b
2 changed files with 27 additions and 9 deletions
@@ -20,7 +20,6 @@ import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
@@ -49,7 +48,7 @@ public final class UnnecessaryUnicodeEscapeInspection extends BaseInspection {
}
@Override
protected @Nullable LocalQuickFix buildFix(Object... infos) {
protected @NotNull LocalQuickFix buildFix(Object... infos) {
return new UnnecessaryUnicodeEscapeFix(((Character) infos[0]).charValue(), (RangeMarker)infos[1]);
}
@@ -136,15 +135,23 @@ public final class UnnecessaryUnicodeEscapeInspection extends BaseInspection {
if (type == Character.CONTROL && d != '\n' && d != '\t') {
continue;
}
else if (type == Character.FORMAT ||
type == Character.PRIVATE_USE ||
type == Character.SURROGATE ||
type == Character.UNASSIGNED ||
type == Character.LINE_SEPARATOR ||
type == Character.PARAGRAPH_SEPARATOR) {
else if (type == Character.SPACE_SEPARATOR && d != ' ') {
continue;
}
if (type == Character.SPACE_SEPARATOR && d != ' ') {
else if (type == Character.FORMAT
|| type == Character.PRIVATE_USE
|| type == Character.SURROGATE
|| type == Character.UNASSIGNED
|| type == Character.LINE_SEPARATOR
|| type == Character.PARAGRAPH_SEPARATOR) {
continue;
}
Character.UnicodeBlock block = Character.UnicodeBlock.of(d);
if (block == Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS
|| block == Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS_EXTENDED
|| block == Character.UnicodeBlock.COMBINING_DIACRITICAL_MARKS_SUPPLEMENT
|| block == Character.UnicodeBlock.COMBINING_HALF_MARKS
|| block == Character.UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS) {
continue;
}
byteBuffer.clear();
@@ -1,4 +1,15 @@
class UnnecessaryUnicodeEscapeUTF8 {
char replacement = '\uFFFD';
public void foo() {
var stroke1 = '\u0336';
var stroke2 = '̶';
var hook1 = '\u0309';
var hook2 = '̉';
var macron1 = '\ufe24';
var macron2 = '︤';
}
}