mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-13 15:52:11 +00:00
Move 'radixPrefix' from compiler modules to IDE modules
`radixPrefix` is used only in IDE now. So let's put it into IDE modules. This commit is done in order to be able to use code dependent on `radixPrefix` in `kotlin-ide` repo, because `kotlin-ide` depends on 1.4.0 artifacts of compiler. And `radixPrefix` isn't presented in those artifacts
This commit is contained in:
@@ -23,11 +23,3 @@ fun extractRadix(value: String): NumberWithRadix = when {
|
||||
value.startsWith("0b") || value.startsWith("0B") -> NumberWithRadix(value.substring(2), 2)
|
||||
else -> NumberWithRadix(value, 10)
|
||||
}
|
||||
|
||||
val NumberWithRadix.radixPrefix: String
|
||||
get() = when (radix) {
|
||||
2 -> "0b"
|
||||
10 -> ""
|
||||
16 -> "0x"
|
||||
else -> error("Invalid radix for $this")
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import org.jetbrains.kotlin.nj2k.tree.*
|
||||
import org.jetbrains.kotlin.nj2k.types.JKJavaArrayType
|
||||
import org.jetbrains.kotlin.nj2k.types.JKJavaPrimitiveType
|
||||
import org.jetbrains.kotlin.nj2k.types.JKNoType
|
||||
import org.jetbrains.kotlin.utils.NumberWithRadix
|
||||
import org.jetbrains.kotlin.utils.extractRadix
|
||||
import org.jetbrains.kotlin.utils.radixPrefix
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
@@ -231,6 +231,14 @@ class ForConversion(context: NewJ2kConverterContext) : RecursiveApplicableConver
|
||||
return "${numberWithRadix.radixPrefix}${fixedValue}"
|
||||
}
|
||||
|
||||
private val NumberWithRadix.radixPrefix: String
|
||||
get() = when (radix) {
|
||||
2 -> "0b"
|
||||
10 -> ""
|
||||
16 -> "0x"
|
||||
else -> error("Invalid radix for $this")
|
||||
}
|
||||
|
||||
private fun indicesIterationRange(
|
||||
start: JKExpression,
|
||||
bound: JKExpression,
|
||||
|
||||
Reference in New Issue
Block a user