Add codePointBefore to idea-flex-kotlin.skeleton

Merge-request: FLEET-MR-6833
Merged-by: Boris Krylov <Boris.Krylov@jetbrains.com>

GitOrigin-RevId: 0bab640f1e1d5a44f4df277db9c99e0ca371ee63
This commit is contained in:
Boris Krylov
2025-10-02 19:39:29 +00:00
committed by intellij-monorepo-bot
parent c6335b5ae9
commit 35bcf69e0a
+11
View File
@@ -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.