mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[diff] fix KMP compilation
GitOrigin-RevId: b8d5347096a8168353c8a49990e12a97e3ad5fd5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f23ca8f7e4
commit
fd2efb1197
@@ -1,6 +1,8 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.diff.comparison
|
||||
|
||||
import com.intellij.util.diff.binarySearch
|
||||
|
||||
/** Returns the character (Unicode code point) at the specified index. */
|
||||
internal fun CharSequence.codePointAt(index: Int): Int {
|
||||
val high = this[index]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.diff.tools.util.text
|
||||
|
||||
import com.intellij.util.diff.binarySearch
|
||||
import com.intellij.util.fastutil.ints.IntArrayList
|
||||
import com.intellij.util.fastutil.ints.toArray
|
||||
import kotlin.jvm.JvmStatic
|
||||
@@ -64,22 +65,3 @@ class LineOffsetsImpl private constructor(private val myLineEnds: IntArray, over
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun IntArray.binarySearch(element: Int): Int {
|
||||
var l = 0
|
||||
var r = size - 1
|
||||
|
||||
while (l <= r) {
|
||||
val m = (l + r) / 2
|
||||
val midElement = get(m)
|
||||
|
||||
if (midElement < element) {
|
||||
l = m + 1
|
||||
} else if (midElement > element) {
|
||||
r = m - 1
|
||||
} else {
|
||||
return m
|
||||
}
|
||||
}
|
||||
return -(l + 1)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.diff.fragments.MergeLineFragment
|
||||
import com.intellij.diff.fragments.MergeWordFragment
|
||||
import com.intellij.diff.tools.util.text.LineOffsets
|
||||
import com.intellij.diff.util.DiffRangeUtil.getLinesContent
|
||||
import kotlin.jvm.JvmStatic
|
||||
|
||||
object MergeRangeUtil {
|
||||
@JvmStatic
|
||||
|
||||
@@ -118,7 +118,7 @@ class Reindexer {
|
||||
|
||||
companion object {
|
||||
private fun createSorted(ints1: IntArray): IntArray {
|
||||
val sorted1 = ints1.clone()
|
||||
val sorted1 = ints1.copyOf()
|
||||
sorted1.sort()
|
||||
return sorted1
|
||||
}
|
||||
@@ -139,9 +139,11 @@ class Reindexer {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun IntArray.binarySearch(element: Int): Int {
|
||||
var l = 0
|
||||
var r = size - 1
|
||||
internal fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size): Int {
|
||||
rangeCheck(size, fromIndex, toIndex)
|
||||
|
||||
var l = fromIndex
|
||||
var r = toIndex - 1
|
||||
|
||||
while (l <= r) {
|
||||
val m = (l + r) / 2
|
||||
@@ -157,3 +159,11 @@ internal fun IntArray.binarySearch(element: Int): Int {
|
||||
}
|
||||
return -(l + 1)
|
||||
}
|
||||
|
||||
private fun rangeCheck(size: Int, fromIndex: Int, toIndex: Int) {
|
||||
when {
|
||||
fromIndex > toIndex -> throw IllegalArgumentException("fromIndex ($fromIndex) is greater than toIndex ($toIndex).")
|
||||
fromIndex < 0 -> throw IndexOutOfBoundsException("fromIndex ($fromIndex) is less than zero.")
|
||||
toIndex > size -> throw IndexOutOfBoundsException("toIndex ($toIndex) is greater than size ($size).")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user