void (@NotNull PsiLiteralExpression expression) { super.visitLiteralExpression(expression); if (!ExpressionUtils.hasStringType(expression)) { return; } final String text = expression.getText(); int escapeStart = -1; while (true) { escapeStart = text.indexOf('\\', escapeStart + 1); if (escapeStart < 0) { return; } if (escapeStart > 0 && text.charAt(escapeStart - 1) == '\\') { continue; } boolean isEscape = true; final int textLength = text.length(); int nextChar = escapeStart + 1; while (nextChar < textLength && text.charAt(nextChar) == '\\') { isEscape = !isEscape; nextChar++; } if (!isEscape) { continue; } escapeStart = nextChar - 1; int length = 1; // see JLS 3.10.6. Escape Sequences for Character and String Literals boolean zeroToThree = false; while (escapeStart + length < textLength) { final char c = text.charAt(escapeStart + length); if (c < '0' || c > '9') { break; } if (length == 1 && (c == '0' || c == '1' || c == '2' || c == '3')) { zeroToThree = true; } if (c == '8' || c == '9' || (length > 2 && !zeroToThree) || length > 3) { registerErrorAtOffset(expression, escapeStart, length); break; } length++; } } }