Migrate compiler, idea and others to new case conversion api
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@ abstract class AbstractBuilderConfigurator<T : AbstractFirTreeBuilder>(val firTr
|
||||
thisRef: Nothing?,
|
||||
prop: KProperty<*>
|
||||
): ReadOnlyProperty<Nothing?, IntermediateBuilder> {
|
||||
val name = name ?: "Fir${prop.name.capitalize()}"
|
||||
val name = name ?: "Fir${prop.name.replaceFirstChar(Char::uppercaseChar)}"
|
||||
builder = IntermediateBuilder(name).apply {
|
||||
firTreeBuilder.intermediateBuilders += this
|
||||
IntermediateBuilderConfigurationContext(this).block()
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ abstract class AbstractFieldConfigurator<T : AbstractFirTreeBuilder>(private val
|
||||
|
||||
fun generateBooleanFields(vararg names: String) {
|
||||
names.forEach {
|
||||
+booleanField("is${it.capitalize()}")
|
||||
+booleanField("is${it.replaceFirstChar(Char::uppercaseChar)}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ fun field(name: String, typeWithArgs: Pair<Type, List<Importable>>, nullable: Bo
|
||||
}
|
||||
|
||||
fun field(type: Type, nullable: Boolean = false, withReplace: Boolean = false): Field {
|
||||
return SimpleField(type.type.decapitalize(), type.typeWithArguments, type.packageName, null, nullable, withReplace)
|
||||
return SimpleField(type.type.replaceFirstChar(Char::lowercaseChar), type.typeWithArguments, type.packageName, null, nullable, withReplace)
|
||||
}
|
||||
|
||||
fun booleanField(name: String, withReplace: Boolean = false): Field {
|
||||
@@ -57,7 +57,7 @@ fun field(name: String, element: AbstractElement, nullable: Boolean = false, wit
|
||||
}
|
||||
|
||||
fun field(element: Element, nullable: Boolean = false, withReplace: Boolean = false): Field {
|
||||
return FirField(element.name.decapitalize(), element, nullable, withReplace)
|
||||
return FirField(element.name.replaceFirstChar(Char::lowercaseChar), element, nullable, withReplace)
|
||||
}
|
||||
|
||||
// ----------- Field list -----------
|
||||
@@ -67,7 +67,7 @@ fun fieldList(name: String, type: Importable, withReplace: Boolean = false): Fie
|
||||
}
|
||||
|
||||
fun fieldList(element: Element, withReplace: Boolean = false): Field {
|
||||
return FieldList(element.name.decapitalize() + "s", element, withReplace)
|
||||
return FieldList(element.name.replaceFirstChar(Char::lowercaseChar) + "s", element, withReplace)
|
||||
}
|
||||
|
||||
// ----------- Field set -----------
|
||||
|
||||
+3
-3
@@ -228,7 +228,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
||||
|
||||
field.needsSeparateTransform -> {
|
||||
if (!(element.needTransformOtherChildren && field.needTransformInOtherChildren)) {
|
||||
println("transform${field.name.capitalize()}(transformer, data)")
|
||||
println("transform${field.name.replaceFirstChar(Char::uppercaseChar)}(transformer, data)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
||||
field.transform()
|
||||
}
|
||||
if (field.needTransformInOtherChildren) {
|
||||
println("transform${field.name.capitalize()}(transformer, data)")
|
||||
println("transform${field.name.replaceFirstChar(Char::uppercaseChar)}(transformer, data)")
|
||||
}
|
||||
}
|
||||
println("return this")
|
||||
@@ -335,7 +335,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
||||
}
|
||||
|
||||
for (field in allFields.filter { it.withReplace }) {
|
||||
val capitalizedFieldName = field.name.capitalize()
|
||||
val capitalizedFieldName = field.name.replaceFirstChar(Char::uppercaseChar)
|
||||
val newValue = "new$capitalizedFieldName"
|
||||
generateReplace(field, forceNullable = field.useNullableForReplace) {
|
||||
when {
|
||||
|
||||
+3
-3
@@ -96,7 +96,7 @@ val Field.isVal: Boolean get() = this is FieldList || (this is FieldWithDefault
|
||||
|
||||
|
||||
fun Field.transformFunctionDeclaration(returnType: String): String {
|
||||
return transformFunctionDeclaration(name.capitalize(), returnType)
|
||||
return transformFunctionDeclaration(name.replaceFirstChar(Char::uppercaseChar), returnType)
|
||||
}
|
||||
|
||||
fun transformFunctionDeclaration(transformName: String, returnType: String): String {
|
||||
@@ -104,7 +104,7 @@ fun transformFunctionDeclaration(transformName: String, returnType: String): Str
|
||||
}
|
||||
|
||||
fun Field.replaceFunctionDeclaration(overridenType: Importable? = null, forceNullable: Boolean = false): String {
|
||||
val capName = name.capitalize()
|
||||
val capName = name.replaceFirstChar(Char::uppercaseChar)
|
||||
val type = overridenType?.typeWithArguments ?: typeWithArguments
|
||||
|
||||
val typeWithNullable = if (forceNullable && !type.endsWith("?")) "$type?" else type
|
||||
@@ -136,7 +136,7 @@ fun Implementation.Kind?.braces(): String = when (this) {
|
||||
else -> throw IllegalStateException(this.toString())
|
||||
}
|
||||
|
||||
val Element.safeDecapitalizedName: String get() = if (name == "Class") "klass" else name.decapitalize()
|
||||
val Element.safeDecapitalizedName: String get() = if (name == "Class") "klass" else name.replaceFirstChar(Char::lowercaseChar)
|
||||
|
||||
val Importable.typeWithArguments: String
|
||||
get() = when (this) {
|
||||
|
||||
Reference in New Issue
Block a user