Migrate compiler, idea and others to new case conversion api

This commit is contained in:
Abduqodiri Qurbonzoda
2021-04-08 02:28:57 +03:00
parent aa543c6631
commit 40d1849f33
138 changed files with 239 additions and 224 deletions
@@ -160,10 +160,10 @@ class Generator(
get() = "val $fieldName: $setType"
private val Alias.fieldName: String
get() = removePrefix("Fir").decapitalize() + "s"
get() = removePrefix("Fir").replaceFirstChar(Char::lowercaseChar) + "s"
private val Alias.allFieldName: String
get() = "all${fieldName.capitalize()}"
get() = "all${fieldName.replaceFirstChar(Char::uppercaseChar)}"
private val Alias.setType: String
get() = "Set<$this>"
@@ -124,7 +124,7 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
get() = classifier as KClass<*>
private fun DiagnosticData.getFactoryFunction(): String =
severity.name.toLowerCase() + parameters.size
severity.name.lowercase() + parameters.size
}
private inline fun <T> SmartPrinter.printSeparatedWithComma(list: List<T>, printItem: (T) -> Unit) {
@@ -520,7 +520,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
private fun FlowContent.modality(modality: Modality?) {
if (modality == null) return
keyword(modality.name.toLowerCase())
keyword(modality.name.lowercase())
}
private fun FlowContent.visibility(visibility: Visibility) {
@@ -41,7 +41,7 @@ class Modifier(
parameterModifiers += ParameterModifier.CONST
return
}
val upperCasedModifier = modifier.toString().toUpperCase()
val upperCasedModifier = modifier.toString().uppercase()
when {
INLINE_MODIFIER.contains(tokenType) -> {
if (isInClass)
@@ -20,9 +20,9 @@ class TypeParameterModifier(
fun addModifier(modifier: LighterASTNode) {
val tokenType = modifier.tokenType
when {
VARIANCE_MODIFIER.contains(tokenType) -> this.varianceModifiers += VarianceModifier.valueOf(modifier.toString().toUpperCase())
VARIANCE_MODIFIER.contains(tokenType) -> this.varianceModifiers += VarianceModifier.valueOf(modifier.toString().uppercase())
REIFICATION_MODIFIER.contains(tokenType) -> this.reificationModifier =
ReificationModifier.valueOf(modifier.toString().toUpperCase())
ReificationModifier.valueOf(modifier.toString().uppercase())
}
}
@@ -20,7 +20,7 @@ class TypeProjectionModifier(
fun addModifier(modifier: LighterASTNode) {
val tokenType = modifier.tokenType
when {
VARIANCE_MODIFIER.contains(tokenType) -> this.varianceModifiers += VarianceModifier.valueOf(modifier.toString().toUpperCase())
VARIANCE_MODIFIER.contains(tokenType) -> this.varianceModifiers += VarianceModifier.valueOf(modifier.toString().uppercase())
}
}
@@ -82,7 +82,7 @@ class TotalKotlinTest : AbstractRawFirBuilderTestCase() {
if (file.isDirectory) continue
/* TODO: fix this, please !!! */
if (file.path.contains("kotlin-native") ||
file.path.toLowerCase().contains("testdata") ||
file.path.lowercase().contains("testdata") ||
file.path.contains("resources")
) continue
if (file.extension != "kt") continue
@@ -52,7 +52,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
println("BASE PATH: $testDataPath")
for (file in root.walkTopDown()) {
if (file.isDirectory) continue
val path = file.path.toLowerCase()
val path = file.path.lowercase()
if ("testdata" in path ||
"kotlin-native" in path ||
"resources" in path ||
@@ -180,7 +180,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
val root = File(testDataPath)
for (file in root.walkTopDown()) {
if (file.isDirectory) continue
val path = file.path.toLowerCase()
val path = file.path.lowercase()
if ("kotlin-native" in path ||
"testdata" in path ||
"resources" in path ||
@@ -211,7 +211,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
var counter = 0
for (file in root.walkTopDown()) {
if (file.isDirectory) continue
val path = file.path.toLowerCase()
val path = file.path.lowercase()
if ("kotlin-native" in path ||
"testdata" in path ||
"resources" in path ||
@@ -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()
@@ -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)}")
}
}
@@ -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 -----------
@@ -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 {
@@ -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) {