From 35bcf69e0ad0a365e1aef2316b42bae3fdd90d23 Mon Sep 17 00:00:00 2001 From: Boris Krylov Date: Thu, 2 Oct 2025 19:39:29 +0000 Subject: [PATCH] Add codePointBefore to idea-flex-kotlin.skeleton Merge-request: FLEET-MR-6833 Merged-by: Boris Krylov GitOrigin-RevId: 0bab640f1e1d5a44f4df277db9c99e0ca371ee63 --- tools/lexer/idea-flex-kotlin.skeleton | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/lexer/idea-flex-kotlin.skeleton b/tools/lexer/idea-flex-kotlin.skeleton index e241f679f5ba..49882c195f9b 100644 --- a/tools/lexer/idea-flex-kotlin.skeleton +++ b/tools/lexer/idea-flex-kotlin.skeleton @@ -201,6 +201,17 @@ companion object { private fun charCount(codePoint: Int): Int = if (codePoint < 0x10000) 1 else 2 + private fun Char.Companion.codePointBefore(seq: CharSequence, index: Int): Int { + var i = index - 1 + val c2 = seq[i]; + if (c2.isLowSurrogate() && index > 0) { + val c1 = seq[i - 1]; + if (c1.isHighSurrogate()) { + return Char.toCodePoint(c1, c2); + } + } + return c2.code + } /** * Reports an error that occurred while scanning.