[K/N] Migrate compiler, interop and others to new case conversion api

This commit is contained in:
Abduqodiri Qurbonzoda
2021-04-08 02:34:32 +03:00
parent a4839b8548
commit 983985bc68
13 changed files with 32 additions and 31 deletions
@@ -224,12 +224,12 @@ object KotlinTypes {
private open class ClassifierAtPackage(val pkg: String) {
operator fun getValue(thisRef: KotlinTypes, property: KProperty<*>): Classifier =
Classifier.topLevel(pkg, property.name.capitalize())
Classifier.topLevel(pkg, property.name.replaceFirstChar(Char::uppercaseChar))
}
private open class TypeAtPackage(val pkg: String) {
operator fun getValue(thisRef: KotlinTypes, property: KProperty<*>): KotlinClassifierType =
Classifier.topLevel(pkg, property.name.capitalize()).type
Classifier.topLevel(pkg, property.name.replaceFirstChar(Char::uppercaseChar)).type
}
private object BuiltInType : TypeAtPackage("kotlin")
@@ -56,7 +56,7 @@ private fun ObjCMethod.getFirstKotlinParameterNameCandidate(forConstructorOrFact
val selectorPart = this.selector.takeWhile { it != ':' }.trimStart('_')
if (selectorPart.startsWith("init")) {
selectorPart.removePrefix("init").removePrefix("With")
.takeIf { it.isNotEmpty() }?.let { return it.decapitalize() }
.takeIf { it.isNotEmpty() }?.let { return it.replaceFirstChar(Char::lowercaseChar) }
}
}
@@ -69,7 +69,7 @@ private fun ObjCMethod.getKotlinParameters(
): List<FunctionParameterStub> {
if (this.isInit && this.parameters.isEmpty() && this.selector != "init") {
// Create synthetic Unit parameter, just like Swift does in this case:
val parameterName = this.selector.removePrefix("init").removePrefix("With").decapitalize()
val parameterName = this.selector.removePrefix("init").removePrefix("With").replaceFirstChar(Char::lowercaseChar)
return listOf(FunctionParameterStub(parameterName, KotlinTypes.unit.toStubIrType()))
// Note: this parameter is explicitly handled in compiler.
}
@@ -392,7 +392,7 @@ internal class EnumStubBuilder(
)
}
private fun EnumConstant.isMoreCanonicalThan(other: EnumConstant): Boolean = with(other.name.toLowerCase()) {
private fun EnumConstant.isMoreCanonicalThan(other: EnumConstant): Boolean = with(other.name.lowercase()) {
contains("min") || contains("max") ||
contains("first") || contains("last") ||
contains("begin") || contains("end")
@@ -128,7 +128,7 @@ class JSInteropArguments(argParser: ArgParser = ArgParser("jsinterop",
enum class TargetType {
WASM32;
override fun toString() = name.toLowerCase()
override fun toString() = name.lowercase()
}
val target by argParser.option(ArgType.Choice<TargetType>(),
description = "wasm target to compile to").default(TargetType.WASM32)