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
@@ -262,7 +262,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
private fun getFlavorUnitTestFolder(flavourName: String): String { private fun getFlavorUnitTestFolder(flavourName: String): String {
return pathManager.srcFolderInAndroidTmpFolder + return pathManager.srcFolderInAndroidTmpFolder +
"/androidTest${flavourName.capitalize()}/java/" + "/androidTest${flavourName.replaceFirstChar(Char::uppercaseChar)}/java/" +
testClassPackage.replace(".", "/") + "/" testClassPackage.replace(".", "/") + "/"
} }
@@ -379,7 +379,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
configure(backend) configure(backend)
testInfo = KotlinTestInfo( testInfo = KotlinTestInfo(
"org.jetbrains.kotlin.android.tests.AndroidRunner", "org.jetbrains.kotlin.android.tests.AndroidRunner",
"test${testDataFile.nameWithoutExtension.capitalize()}", "test${testDataFile.nameWithoutExtension.replaceFirstChar(Char::uppercaseChar)}",
emptySet() emptySet()
) )
}.build(testDataFile.path) }.build(testDataFile.path)
@@ -27,7 +27,7 @@ class UnitTestFileWriter(
} }
fun generate() { fun generate() {
FileWriter(File(flavourFolder, flavourName.capitalize() + ".java").also { it.parentFile.mkdirs() }).use { suite -> FileWriter(File(flavourFolder, flavourName.replaceFirstChar(Char::uppercaseChar) + ".java").also { it.parentFile.mkdirs() }).use { suite ->
val p = Printer(suite) val p = Printer(suite)
p.println( p.println(
"""package ${CodegenTestsOnAndroidGenerator.testClassPackage}; """package ${CodegenTestsOnAndroidGenerator.testClassPackage};
@@ -35,7 +35,7 @@ class UnitTestFileWriter(
|import ${CodegenTestsOnAndroidGenerator.baseTestClassPackage}.${CodegenTestsOnAndroidGenerator.baseTestClassName}; |import ${CodegenTestsOnAndroidGenerator.baseTestClassPackage}.${CodegenTestsOnAndroidGenerator.baseTestClassName};
| |
|/* This class is generated by ${CodegenTestsOnAndroidGenerator.generatorName}. DO NOT MODIFY MANUALLY */ |/* This class is generated by ${CodegenTestsOnAndroidGenerator.generatorName}. DO NOT MODIFY MANUALLY */
|public class ${flavourName.capitalize()} extends ${CodegenTestsOnAndroidGenerator.baseTestClassName} { |public class ${flavourName.replaceFirstChar(Char::uppercaseChar)} extends ${CodegenTestsOnAndroidGenerator.baseTestClassName} {
| |
""".trimMargin() """.trimMargin()
) )
@@ -28,7 +28,7 @@ object ChangeBoxingMethodTransformer : MethodTransformer() {
val map = hashMapOf<String, String>() val map = hashMapOf<String, String>()
for (primitiveType in JvmPrimitiveType.values()) { for (primitiveType in JvmPrimitiveType.values()) {
val name = primitiveType.wrapperFqName.topLevelClassInternalName() val name = primitiveType.wrapperFqName.topLevelClassInternalName()
map[name] = "box${primitiveType.javaKeywordName.capitalize(Locale.US)}" map[name] = "box${primitiveType.javaKeywordName.replaceFirstChar(Char::uppercaseChar)}"
} }
wrapperToInternalBoxing = map wrapperToInternalBoxing = map
} }
@@ -63,9 +63,9 @@ enum class CompilerSystemProperties(val property: String) {
} }
val isWindows: Boolean val isWindows: Boolean
get() = CompilerSystemProperties.OS_NAME.value!!.toLowerCase(Locale.ENGLISH).startsWith("windows") get() = CompilerSystemProperties.OS_NAME.value!!.lowercase().startsWith("windows")
fun String?.toBooleanLenient(): Boolean? = when (this?.toLowerCase()) { fun String?.toBooleanLenient(): Boolean? = when (this?.lowercase()) {
null -> false null -> false
in listOf("", "yes", "true", "on", "y") -> true in listOf("", "yes", "true", "on", "y") -> true
in listOf("no", "false", "off", "n") -> false in listOf("no", "false", "off", "n") -> false
@@ -432,7 +432,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
fun DceRuntimeDiagnostic.Companion.resolve( fun DceRuntimeDiagnostic.Companion.resolve(
value: String?, value: String?,
messageCollector: MessageCollector messageCollector: MessageCollector
): DceRuntimeDiagnostic? = when (value?.toLowerCase()) { ): DceRuntimeDiagnostic? = when (value?.lowercase()) {
DCE_RUNTIME_DIAGNOSTIC_LOG -> DceRuntimeDiagnostic.LOG DCE_RUNTIME_DIAGNOSTIC_LOG -> DceRuntimeDiagnostic.LOG
DCE_RUNTIME_DIAGNOSTIC_EXCEPTION -> DceRuntimeDiagnostic.EXCEPTION DCE_RUNTIME_DIAGNOSTIC_EXCEPTION -> DceRuntimeDiagnostic.EXCEPTION
null -> null null -> null
@@ -125,7 +125,7 @@ object CompilerOutputParser {
// We're directly inside the root tag: <MESSAGES> // We're directly inside the root tag: <MESSAGES>
return return
} }
val qNameLowerCase = qName.toLowerCase(Locale.US) val qNameLowerCase = qName.lowercase()
var category: CompilerMessageSeverity? = CATEGORIES[qNameLowerCase] var category: CompilerMessageSeverity? = CATEGORIES[qNameLowerCase]
if (category == null) { if (category == null) {
messageCollector.report(ERROR, "Unknown compiler message tag: $qName") messageCollector.report(ERROR, "Unknown compiler message tag: $qName")
@@ -107,7 +107,7 @@ private inline fun tryConnectToDaemon(port: Int, report: (DaemonReportCategory,
private const val validFlagFileKeywordChars = "abcdefghijklmnopqrstuvwxyz0123456789-_" private const val validFlagFileKeywordChars = "abcdefghijklmnopqrstuvwxyz0123456789-_"
fun makeAutodeletingFlagFile(keyword: String = "compiler-client", baseDir: File? = null): File { fun makeAutodeletingFlagFile(keyword: String = "compiler-client", baseDir: File? = null): File {
val prefix = "kotlin-${keyword.filter { validFlagFileKeywordChars.contains(it.toLowerCase()) }}-" val prefix = "kotlin-${keyword.filter { validFlagFileKeywordChars.contains(it.lowercaseChar()) }}-"
val flagFile = if (baseDir?.isDirectory == true) val flagFile = if (baseDir?.isDirectory == true)
Files.createTempFile(baseDir.toPath(), prefix, "-is-running").toFile() Files.createTempFile(baseDir.toPath(), prefix, "-is-running").toFile()
else else
@@ -352,7 +352,7 @@ private val humanizedMemorySizeRegex = "(\\d+)([kmg]?)".toRegex()
private fun String.memToBytes(): Long? = private fun String.memToBytes(): Long? =
humanizedMemorySizeRegex humanizedMemorySizeRegex
.matchEntire(this.trim().toLowerCase()) .matchEntire(this.trim().lowercase())
?.groups?.let { match -> ?.groups?.let { match ->
match[1]?.value?.let { match[1]?.value?.let {
it.toLong() * it.toLong() *
@@ -114,7 +114,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
} }
fun isClasspathFile(file: File): Boolean = file.isFile && listOf("class", "jar").contains(file.extension.toLowerCase()) fun isClasspathFile(file: File): Boolean = file.isFile && listOf("class", "jar").contains(file.extension.lowercase())
fun File.md5Digest(): ByteArray { fun File.md5Digest(): ByteArray {
val md = MessageDigest.getInstance(CLASSPATH_FILE_ID_DIGEST) val md = MessageDigest.getInstance(CLASSPATH_FILE_ID_DIGEST)
@@ -160,10 +160,10 @@ class Generator(
get() = "val $fieldName: $setType" get() = "val $fieldName: $setType"
private val Alias.fieldName: String private val Alias.fieldName: String
get() = removePrefix("Fir").decapitalize() + "s" get() = removePrefix("Fir").replaceFirstChar(Char::lowercaseChar) + "s"
private val Alias.allFieldName: String private val Alias.allFieldName: String
get() = "all${fieldName.capitalize()}" get() = "all${fieldName.replaceFirstChar(Char::uppercaseChar)}"
private val Alias.setType: String private val Alias.setType: String
get() = "Set<$this>" get() = "Set<$this>"
@@ -124,7 +124,7 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() {
get() = classifier as KClass<*> get() = classifier as KClass<*>
private fun DiagnosticData.getFactoryFunction(): String = 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) { 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?) { private fun FlowContent.modality(modality: Modality?) {
if (modality == null) return if (modality == null) return
keyword(modality.name.toLowerCase()) keyword(modality.name.lowercase())
} }
private fun FlowContent.visibility(visibility: Visibility) { private fun FlowContent.visibility(visibility: Visibility) {
@@ -41,7 +41,7 @@ class Modifier(
parameterModifiers += ParameterModifier.CONST parameterModifiers += ParameterModifier.CONST
return return
} }
val upperCasedModifier = modifier.toString().toUpperCase() val upperCasedModifier = modifier.toString().uppercase()
when { when {
INLINE_MODIFIER.contains(tokenType) -> { INLINE_MODIFIER.contains(tokenType) -> {
if (isInClass) if (isInClass)
@@ -20,9 +20,9 @@ class TypeParameterModifier(
fun addModifier(modifier: LighterASTNode) { fun addModifier(modifier: LighterASTNode) {
val tokenType = modifier.tokenType val tokenType = modifier.tokenType
when { 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 = 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) { fun addModifier(modifier: LighterASTNode) {
val tokenType = modifier.tokenType val tokenType = modifier.tokenType
when { 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 if (file.isDirectory) continue
/* TODO: fix this, please !!! */ /* TODO: fix this, please !!! */
if (file.path.contains("kotlin-native") || if (file.path.contains("kotlin-native") ||
file.path.toLowerCase().contains("testdata") || file.path.lowercase().contains("testdata") ||
file.path.contains("resources") file.path.contains("resources")
) continue ) continue
if (file.extension != "kt") continue if (file.extension != "kt") continue
@@ -52,7 +52,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
println("BASE PATH: $testDataPath") println("BASE PATH: $testDataPath")
for (file in root.walkTopDown()) { for (file in root.walkTopDown()) {
if (file.isDirectory) continue if (file.isDirectory) continue
val path = file.path.toLowerCase() val path = file.path.lowercase()
if ("testdata" in path || if ("testdata" in path ||
"kotlin-native" in path || "kotlin-native" in path ||
"resources" in path || "resources" in path ||
@@ -180,7 +180,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
val root = File(testDataPath) val root = File(testDataPath)
for (file in root.walkTopDown()) { for (file in root.walkTopDown()) {
if (file.isDirectory) continue if (file.isDirectory) continue
val path = file.path.toLowerCase() val path = file.path.lowercase()
if ("kotlin-native" in path || if ("kotlin-native" in path ||
"testdata" in path || "testdata" in path ||
"resources" in path || "resources" in path ||
@@ -211,7 +211,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
var counter = 0 var counter = 0
for (file in root.walkTopDown()) { for (file in root.walkTopDown()) {
if (file.isDirectory) continue if (file.isDirectory) continue
val path = file.path.toLowerCase() val path = file.path.lowercase()
if ("kotlin-native" in path || if ("kotlin-native" in path ||
"testdata" in path || "testdata" in path ||
"resources" in path || "resources" in path ||
@@ -131,7 +131,7 @@ abstract class AbstractBuilderConfigurator<T : AbstractFirTreeBuilder>(val firTr
thisRef: Nothing?, thisRef: Nothing?,
prop: KProperty<*> prop: KProperty<*>
): ReadOnlyProperty<Nothing?, IntermediateBuilder> { ): ReadOnlyProperty<Nothing?, IntermediateBuilder> {
val name = name ?: "Fir${prop.name.capitalize()}" val name = name ?: "Fir${prop.name.replaceFirstChar(Char::uppercaseChar)}"
builder = IntermediateBuilder(name).apply { builder = IntermediateBuilder(name).apply {
firTreeBuilder.intermediateBuilders += this firTreeBuilder.intermediateBuilders += this
IntermediateBuilderConfigurationContext(this).block() IntermediateBuilderConfigurationContext(this).block()
@@ -22,7 +22,7 @@ abstract class AbstractFieldConfigurator<T : AbstractFirTreeBuilder>(private val
fun generateBooleanFields(vararg names: String) { fun generateBooleanFields(vararg names: String) {
names.forEach { 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 { 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 { 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 { 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 ----------- // ----------- Field list -----------
@@ -67,7 +67,7 @@ fun fieldList(name: String, type: Importable, withReplace: Boolean = false): Fie
} }
fun fieldList(element: Element, withReplace: Boolean = false): Field { 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 ----------- // ----------- Field set -----------
@@ -228,7 +228,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
field.needsSeparateTransform -> { field.needsSeparateTransform -> {
if (!(element.needTransformOtherChildren && field.needTransformInOtherChildren)) { 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() field.transform()
} }
if (field.needTransformInOtherChildren) { if (field.needTransformInOtherChildren) {
println("transform${field.name.capitalize()}(transformer, data)") println("transform${field.name.replaceFirstChar(Char::uppercaseChar)}(transformer, data)")
} }
} }
println("return this") println("return this")
@@ -335,7 +335,7 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
} }
for (field in allFields.filter { it.withReplace }) { for (field in allFields.filter { it.withReplace }) {
val capitalizedFieldName = field.name.capitalize() val capitalizedFieldName = field.name.replaceFirstChar(Char::uppercaseChar)
val newValue = "new$capitalizedFieldName" val newValue = "new$capitalizedFieldName"
generateReplace(field, forceNullable = field.useNullableForReplace) { generateReplace(field, forceNullable = field.useNullableForReplace) {
when { when {
@@ -96,7 +96,7 @@ val Field.isVal: Boolean get() = this is FieldList || (this is FieldWithDefault
fun Field.transformFunctionDeclaration(returnType: String): String { 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 { 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 { 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 type = overridenType?.typeWithArguments ?: typeWithArguments
val typeWithNullable = if (forceNullable && !type.endsWith("?")) "$type?" else type 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()) 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 val Importable.typeWithArguments: String
get() = when (this) { get() = when (this) {
@@ -28,7 +28,7 @@ import java.util.*
object PackagePartClassUtils { object PackagePartClassUtils {
@JvmStatic fun getPathHashCode(file: VirtualFile): Int = @JvmStatic fun getPathHashCode(file: VirtualFile): Int =
file.path.toLowerCase().hashCode() file.path.lowercase().hashCode()
private val PART_CLASS_NAME_SUFFIX = "Kt" private val PART_CLASS_NAME_SUFFIX = "Kt"
@@ -36,7 +36,7 @@ object PackagePartClassUtils {
// NB use Locale.ENGLISH so that build is locale-independent. // NB use Locale.ENGLISH so that build is locale-independent.
// See Javadoc on java.lang.String.toUpperCase() for more details. // See Javadoc on java.lang.String.toUpperCase() for more details.
when { when {
Character.isJavaIdentifierStart(str[0]) -> str.substring(0, 1).toLowerCase(Locale.ENGLISH) + str.substring(1) Character.isJavaIdentifierStart(str[0]) -> str.substring(0, 1).lowercase() + str.substring(1)
str[0] == '_' -> str.substring(1) str[0] == '_' -> str.substring(1)
else -> str else -> str
} }
@@ -128,7 +128,7 @@ object Renderers {
else else
declarationWithNameAndKind declarationWithNameAndKind
withPlatform.capitalize() withPlatform.replaceFirstChar(Char::uppercaseChar)
} }
@@ -51,7 +51,7 @@ abstract class KotlinSuppressCache {
} }
fun isSuppressed(psiElement: PsiElement, suppressionKey: String, severity: Severity) = fun isSuppressed(psiElement: PsiElement, suppressionKey: String, severity: Severity) =
isSuppressed(StringSuppressRequest(psiElement, severity, suppressionKey.toLowerCase())) isSuppressed(StringSuppressRequest(psiElement, severity, suppressionKey.lowercase()))
private fun isSuppressed(request: SuppressRequest): Boolean { private fun isSuppressed(request: SuppressRequest): Boolean {
// If diagnostics are reported in a synthetic file generated by KtPsiFactory (dummy.kt), // If diagnostics are reported in a synthetic file generated by KtPsiFactory (dummy.kt),
@@ -158,7 +158,7 @@ abstract class KotlinSuppressCache {
if (arrayValue is ArrayValue) { if (arrayValue is ArrayValue) {
for (value in arrayValue.value) { for (value in arrayValue.value) {
if (value is StringValue) { if (value is StringValue) {
builder.add(value.value.toLowerCase()) builder.add(value.value.lowercase())
} }
} }
} }
@@ -167,7 +167,7 @@ abstract class KotlinSuppressCache {
companion object { companion object {
private fun getDiagnosticSuppressKey(diagnostic: Diagnostic): String = private fun getDiagnosticSuppressKey(diagnostic: Diagnostic): String =
diagnostic.factory.name.toLowerCase() diagnostic.factory.name.lowercase()
private fun isSuppressedByStrings(key: String, strings: Set<String>, severity: Severity): Boolean = private fun isSuppressedByStrings(key: String, strings: Set<String>, severity: Severity): Boolean =
severity == Severity.WARNING && "warnings" in strings || key in strings severity == Severity.WARNING && "warnings" in strings || key in strings
@@ -65,7 +65,7 @@ fun makeIncrementally(
val allExtensions = kotlinExtensions + "java" val allExtensions = kotlinExtensions + "java"
val rootsWalk = sourceRoots.asSequence().flatMap { it.walk() } val rootsWalk = sourceRoots.asSequence().flatMap { it.walk() }
val files = rootsWalk.filter(File::isFile) val files = rootsWalk.filter(File::isFile)
val sourceFiles = files.filter { it.extension.toLowerCase() in allExtensions }.toList() val sourceFiles = files.filter { it.extension.lowercase() in allExtensions }.toList()
val buildHistoryFile = File(cachesDir, "build-history.bin") val buildHistoryFile = File(cachesDir, "build-history.bin")
args.javaSourceRoots = sourceRoots.map { it.absolutePath }.toTypedArray() args.javaSourceRoots = sourceRoots.map { it.absolutePath }.toTypedArray()
val buildReporter = BuildReporter(icReporter = reporter, buildMetricsReporter = DoNothingBuildMetricsReporter) val buildReporter = BuildReporter(icReporter = reporter, buildMetricsReporter = DoNothingBuildMetricsReporter)
@@ -275,7 +275,7 @@ class IncrementalJvmCompilerRunner(
private fun processLookupSymbolsForAndroidLayouts(changedFiles: ChangedFiles.Known): Collection<LookupSymbol> { private fun processLookupSymbolsForAndroidLayouts(changedFiles: ChangedFiles.Known): Collection<LookupSymbol> {
val result = mutableListOf<LookupSymbol>() val result = mutableListOf<LookupSymbol>()
for (file in changedFiles.modified + changedFiles.removed) { for (file in changedFiles.modified + changedFiles.removed) {
if (file.extension.toLowerCase() != "xml") continue if (file.extension.lowercase() != "xml") continue
val layoutName = file.name.substringBeforeLast('.') val layoutName = file.name.substringBeforeLast('.')
result.add(LookupSymbol(ANDROID_LAYOUT_CONTENT_LOOKUP_NAME, layoutName)) result.add(LookupSymbol(ANDROID_LAYOUT_CONTENT_LOOKUP_NAME, layoutName))
} }
@@ -283,7 +283,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
else -> else ->
Modality.FINAL Modality.FINAL
} }
p(modality, defaultModality) { name.toLowerCase() } p(modality, defaultModality) { name.lowercase() }
p(isExternal, "external") p(isExternal, "external")
p(isFakeOverride, customModifier("fake")) p(isFakeOverride, customModifier("fake"))
p(isOverride, "override") p(isOverride, "override")
@@ -302,7 +302,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
p(isData, "data") p(isData, "data")
p(isCompanion, "companion") p(isCompanion, "companion")
p(isFunInterface, "fun") p(isFunInterface, "fun")
p(classKind) { name.toLowerCase().replace('_', ' ') + if (this == ClassKind.ENUM_ENTRY) " class" else "" } p(classKind) { name.lowercase().replace('_', ' ') + if (this == ClassKind.ENUM_ENTRY) " class" else "" }
p(isInfix, "infix") p(isInfix, "infix")
p(isOperator, "operator") p(isOperator, "operator")
} }
@@ -79,7 +79,7 @@ private fun parseLong(text: String): Long? {
} }
private fun parseFloatingLiteral(text: String): Number? { private fun parseFloatingLiteral(text: String): Number? {
if (text.toLowerCase().endsWith('f')) { if (text.lowercase().endsWith('f')) {
return parseFloat(text) return parseFloat(text)
} }
return parseDouble(text) return parseDouble(text)
@@ -72,7 +72,7 @@ open class KotlinStubBaseImpl<T : KtElementImplStub<*>>(parent: StubElement<*>?,
private fun getPropertyName(method: Method): String { private fun getPropertyName(method: Method): String {
val methodName = method.name!! val methodName = method.name!!
if (methodName.startsWith("get")) { if (methodName.startsWith("get")) {
return methodName.substring(3).decapitalize() return methodName.substring(3).replaceFirstChar(Char::lowercaseChar)
} }
return methodName return methodName
} }
@@ -5,7 +5,7 @@ fun String.toDouble(): Double = (+(this.asDynamic())).unsafeCast<Double>().also
TODO() TODO()
} }
fun String.isNaN(): Boolean = when (this.toLowerCase()) { fun String.isNaN(): Boolean = when (this.lowercase()) {
"nan", "+nan", "-nan" -> true "nan", "+nan", "-nan" -> true
else -> false else -> false
} }
@@ -316,7 +316,7 @@ class ModuleStructureExtractorImpl(
} }
private fun parseModulePlatformByName(moduleName: String): TargetPlatform? { private fun parseModulePlatformByName(moduleName: String): TargetPlatform? {
val nameSuffix = moduleName.substringAfterLast("-", "").toUpperCase() val nameSuffix = moduleName.substringAfterLast("-", "").uppercase()
return when { return when {
nameSuffix == "COMMON" -> CommonPlatforms.defaultCommonPlatform nameSuffix == "COMMON" -> CommonPlatforms.defaultCommonPlatform
nameSuffix == "JVM" -> JvmPlatforms.unspecifiedJvmPlatform // TODO(dsavvinov): determine JvmTarget precisely nameSuffix == "JVM" -> JvmPlatforms.unspecifiedJvmPlatform // TODO(dsavvinov): determine JvmTarget precisely
@@ -536,7 +536,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
private fun parseJvmTarget(directiveMap: Directives) = directiveMap[JVM_TARGET]?.let { JvmTarget.fromString(it) } private fun parseJvmTarget(directiveMap: Directives) = directiveMap[JVM_TARGET]?.let { JvmTarget.fromString(it) }
protected fun parseModulePlatformByName(moduleName: String): TargetPlatform? { protected fun parseModulePlatformByName(moduleName: String): TargetPlatform? {
val nameSuffix = moduleName.substringAfterLast("-", "").toUpperCase() val nameSuffix = moduleName.substringAfterLast("-", "").uppercase()
return when { return when {
nameSuffix == "COMMON" -> CommonPlatforms.defaultCommonPlatform nameSuffix == "COMMON" -> CommonPlatforms.defaultCommonPlatform
nameSuffix == "JVM" -> JvmPlatforms.unspecifiedJvmPlatform // TODO(dsavvinov): determine JvmTarget precisely nameSuffix == "JVM" -> JvmPlatforms.unspecifiedJvmPlatform // TODO(dsavvinov): determine JvmTarget precisely
@@ -19,14 +19,14 @@
fun case_1(x: Class?, y: Any) { fun case_1(x: Class?, y: Any) {
x?.prop_12 = if (y is String) "" else throw Exception() x?.prop_12 = if (y is String) "" else throw Exception()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String"), DEBUG_INFO_SMARTCAST!>y<!>.toUpperCase() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String"), DEBUG_INFO_SMARTCAST!>y<!>.uppercase()
} }
// TESTCASE NUMBER: 2 // TESTCASE NUMBER: 2
fun case_2(x: Class?, y: Any) { fun case_2(x: Class?, y: Any) {
x?.prop_9 = y is String || return x?.prop_9 = y is String || return
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!>.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>toUpperCase<!>() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!>.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>uppercase<!>()
} }
/* /*
@@ -37,7 +37,7 @@ fun case_2(x: Class?, y: Any) {
fun case_3(x: Class?, y: Any) { fun case_3(x: Class?, y: Any) {
x?.prop_12 = y as String x?.prop_12 = y as String
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String"), DEBUG_INFO_SMARTCAST!>y<!>.toUpperCase() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String"), DEBUG_INFO_SMARTCAST!>y<!>.uppercase()
} }
/* /*
@@ -48,7 +48,7 @@ fun case_3(x: Class?, y: Any) {
fun case_4(x: Class?, y: Any) { fun case_4(x: Class?, y: Any) {
x?.prop_12 = y as? String ?: return x?.prop_12 = y as? String ?: return
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String"), DEBUG_INFO_SMARTCAST!>y<!>.toUpperCase() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any & kotlin.String"), DEBUG_INFO_SMARTCAST!>y<!>.uppercase()
} }
/* /*
@@ -59,14 +59,14 @@ fun case_4(x: Class?, y: Any) {
fun case_5(x: Class?, y: String?) { fun case_5(x: Class?, y: String?) {
x?.prop_12 = y ?: return x?.prop_12 = y ?: return
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>y<!>.toUpperCase() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>y<!>.uppercase()
} }
// TESTCASE NUMBER: 6 // TESTCASE NUMBER: 6
fun case_6(x: Class?, y: String?) { fun case_6(x: Class?, y: String?) {
x?.prop_9 = y !is String && throw Exception() x?.prop_9 = y !is String && throw Exception()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>y<!><!UNSAFE_CALL!>.<!>toUpperCase() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>y<!><!UNSAFE_CALL!>.<!>uppercase()
} }
/* /*
@@ -77,7 +77,7 @@ fun case_6(x: Class?, y: String?) {
fun case_7(x: Class?, y: String?) { fun case_7(x: Class?, y: String?) {
x?.prop_12 = y!! x?.prop_12 = y!!
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>y<!>.toUpperCase() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>y<!>.uppercase()
} }
/* /*
@@ -88,5 +88,5 @@ fun case_7(x: Class?, y: String?) {
fun case_8(x: Class?, y: String?) { fun case_8(x: Class?, y: String?) {
x?.prop_12 = if (y === null) throw Exception() else "" x?.prop_12 = if (y === null) throw Exception() else ""
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>y<!> <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>y<!>.toUpperCase() <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String & kotlin.String?"), DEBUG_INFO_SMARTCAST!>y<!>.uppercase()
} }
@@ -41,7 +41,7 @@ object TestsJsonMapGenerator {
SECONDARY; SECONDARY;
override fun toString(): String { override fun toString(): String {
return name.toLowerCase() return name.lowercase()
} }
} }
@@ -43,7 +43,7 @@ object TestsStatisticCollector {
val statistic = mutableMapOf<TestArea, SpecTestsStatElement>() val statistic = mutableMapOf<TestArea, SpecTestsStatElement>()
for (specTestArea in TestArea.values()) { for (specTestArea in TestArea.values()) {
val specTestsPath = "$SPEC_TESTDATA_PATH/${specTestArea.name.toLowerCase().replace("_", "/")}/${testLinkedType.testDataPath}" val specTestsPath = "$SPEC_TESTDATA_PATH/${specTestArea.name.lowercase().replace("_", "/")}/${testLinkedType.testDataPath}"
statistic[specTestArea] = statistic[specTestArea] =
SpecTestsStatElement(SpecTestsStatElementType.AREA) SpecTestsStatElement(SpecTestsStatElementType.AREA)
@@ -23,7 +23,7 @@ import java.util.regex.Pattern
object CommonParser { object CommonParser {
fun String.withUnderscores() = replace(" ", "_") fun String.withUnderscores() = replace(" ", "_")
.replace(File.separator, "_") .replace(File.separator, "_")
.toUpperCase() .uppercase()
fun String.splitByComma() = split(Regex(""",\s*""")) fun String.splitByComma() = split(Regex(""",\s*"""))
fun String.splitByPathSeparator() = split(File.separator) fun String.splitByPathSeparator() = split(File.separator)
@@ -85,8 +85,8 @@ private fun parseImplementationTestInfo(testFilePath: String, linkedTestType: Sp
testArea = TestArea.valueOf(testInfoByContentMatcher.group("testArea").withUnderscores()), testArea = TestArea.valueOf(testInfoByContentMatcher.group("testArea").withUnderscores()),
testType = TestType.valueOf(testInfoByContentMatcher.group("testType")), testType = TestType.valueOf(testInfoByContentMatcher.group("testType")),
testNumber = testInfoElements[CommonSpecTestFileInfoElementType.NUMBER]?.content?.toInt() ?: 0, testNumber = testInfoElements[CommonSpecTestFileInfoElementType.NUMBER]?.content?.toInt() ?: 0,
testDescription = fileNameWithoutExtension.toUpperCase()[0] + fileNameWithoutExtension.substring(1) testDescription = fileNameWithoutExtension.uppercase()[0] + fileNameWithoutExtension.substring(1)
.replace(Regex("""([A-Z])"""), " $1").toLowerCase(), .replace(Regex("""([A-Z])"""), " $1").lowercase(),
testInfoElements = testInfoElements, testInfoElements = testInfoElements,
testCasesSet = SpecTestCasesSet(mutableMapOf(), mutableMapOf(), mutableMapOf()), //todo testCasesSet = SpecTestCasesSet(mutableMapOf(), mutableMapOf(), mutableMapOf()), //todo
unexpectedBehavior = testInfoElements.contains(CommonInfoElementType.UNEXPECTED_BEHAVIOUR), unexpectedBehavior = testInfoElements.contains(CommonInfoElementType.UNEXPECTED_BEHAVIOUR),
@@ -24,7 +24,7 @@ object HtmlSpecSentencesMapBuilder {
spec.select("$SECTION_SELECTORS, $PARAGRAPH_SELECTORS, .sentence").forEach { element -> spec.select("$SECTION_SELECTORS, $PARAGRAPH_SELECTORS, .sentence").forEach { element ->
when { when {
element.`is`(SECTION_SELECTORS) -> { element.`is`(SECTION_SELECTORS) -> {
val sectionTag = SectionTag.valueOf(element.tagName().toLowerCase()) val sectionTag = SectionTag.valueOf(element.tagName().lowercase())
while (!currentSectionsPath.empty() && currentSectionsPath.peek().first.level >= sectionTag.level) { while (!currentSectionsPath.empty() && currentSectionsPath.peek().first.level >= sectionTag.level) {
currentSectionsPath.pop() currentSectionsPath.pop()
} }
@@ -242,7 +242,7 @@ object GenerateSteppedRangesCodegenTestData {
private fun PrintWriter.printTestForFunctionAndType(builder: TestBuilder, function: Function, type: Type, asLiteral: Boolean) { private fun PrintWriter.printTestForFunctionAndType(builder: TestBuilder, function: Function, type: Type, asLiteral: Boolean) {
val shouldFail = (builder.expectedValuesOrFailIfNull == null) val shouldFail = (builder.expectedValuesOrFailIfNull == null)
val listVarName = type.type.toLowerCase() + "List" val listVarName = type.type.lowercase() + "List"
if (shouldFail) { if (shouldFail) {
println(" assertFailsWith<IllegalArgumentException> {") println(" assertFailsWith<IllegalArgumentException> {")
} else { } else {
@@ -253,7 +253,7 @@ object GenerateSteppedRangesCodegenTestData {
if (asLiteral) { if (asLiteral) {
println("$indent for (i in ${builder.buildFullLiteral(type, function)}) {") println("$indent for (i in ${builder.buildFullLiteral(type, function)}) {")
} else { } else {
val progressionVarName = type.type.toLowerCase() + "Progression" val progressionVarName = type.type.lowercase() + "Progression"
println("$indent val $progressionVarName = ${builder.buildRangeOnlyExpression(type, function)}") println("$indent val $progressionVarName = ${builder.buildRangeOnlyExpression(type, function)}")
println("$indent for (i in ${builder.buildOnTopOfRangeOnlyVariable(progressionVarName, type)}) {") println("$indent for (i in ${builder.buildOnTopOfRangeOnlyVariable(progressionVarName, type)}) {")
} }
@@ -86,7 +86,7 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
val platformParameters = JvmPlatformParameters( val platformParameters = JvmPlatformParameters(
packagePartProviderFactory = { PackagePartProvider.Empty }, packagePartProviderFactory = { PackagePartProvider.Empty },
moduleByJavaClass = { javaClass -> moduleByJavaClass = { javaClass ->
val moduleName = javaClass.name.asString().toLowerCase().first().toString() val moduleName = javaClass.name.asString().lowercase().first().toString()
modules.first { it._name == moduleName } modules.first { it._name == moduleName }
}, },
useBuiltinsProviderForModule = { false } useBuiltinsProviderForModule = { false }
@@ -165,8 +165,8 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
module -> module ->
val moduleDescriptor = resolverForProject.descriptorForModule(module) val moduleDescriptor = resolverForProject.descriptorForModule(module)
checkClassInPackage(moduleDescriptor, "test", "Kotlin${module._name.toUpperCase()}") checkClassInPackage(moduleDescriptor, "test", "Kotlin${module._name.uppercase()}")
checkClassInPackage(moduleDescriptor, "custom", "${module._name.toUpperCase()}Class") checkClassInPackage(moduleDescriptor, "custom", "${module._name.uppercase()}Class")
} }
} }
@@ -229,7 +229,7 @@ class MultiModuleJavaAnalysisCustomTest : KtUsefulTestCase() {
assert(!ErrorUtils.isError(referencedDescriptor)) { "Error descriptor: $referencedDescriptor" } assert(!ErrorUtils.isError(referencedDescriptor)) { "Error descriptor: $referencedDescriptor" }
val descriptorName = referencedDescriptor.name.asString() val descriptorName = referencedDescriptor.name.asString()
val expectedModuleName = "<${descriptorName.toLowerCase().first()}>" val expectedModuleName = "<${descriptorName.lowercase().first()}>"
val moduleName = referencedDescriptor.module.name.asString() val moduleName = referencedDescriptor.module.name.asString()
Assert.assertEquals( Assert.assertEquals(
"Java class $descriptorName in $context should be in module $expectedModuleName, but instead was in $moduleName", "Java class $descriptorName in $context should be in module $expectedModuleName, but instead was in $moduleName",
@@ -206,7 +206,7 @@ enum class LanguageFeature(
val presentableName: String val presentableName: String
// E.g. "DestructuringLambdaParameters" -> ["Destructuring", "Lambda", "Parameters"] -> "destructuring lambda parameters" // E.g. "DestructuringLambdaParameters" -> ["Destructuring", "Lambda", "Parameters"] -> "destructuring lambda parameters"
get() = name.split("(?<!^)(?=[A-Z])".toRegex()).joinToString(separator = " ", transform = String::toLowerCase) get() = name.split("(?<!^)(?=[A-Z])".toRegex()).joinToString(separator = " ", transform = String::lowercase)
val presentableText get() = if (hintUrl == null) presentableName else "$presentableName (See: $hintUrl)" val presentableText get() = if (hintUrl == null) presentableName else "$presentableName (See: $hintUrl)"
@@ -827,7 +827,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
val name = arrayOfCall.typeRef.coneType.classId!!.shortClassName.asString() val name = arrayOfCall.typeRef.coneType.classId!!.shortClassName.asString()
val typeArguments = arrayOfCall.typeRef.coneType.typeArguments val typeArguments = arrayOfCall.typeRef.coneType.typeArguments
val typeParameters = if (typeArguments.isEmpty()) "" else " <T>" val typeParameters = if (typeArguments.isEmpty()) "" else " <T>"
data.append("fun$typeParameters ${name.decapitalize()}Of") data.append("fun$typeParameters ${name.replaceFirstChar(Char::lowercaseChar)}Of")
typeArguments.firstOrNull()?.let { typeArguments.firstOrNull()?.let {
data.append("<").append(it.tryToRenderConeAsFunctionType()).append(">") data.append("<").append(it.tryToRenderConeAsFunctionType()).append(">")
} }
@@ -39,10 +39,10 @@ object NameUtils {
@JvmStatic @JvmStatic
private fun capitalizeAsJavaClassName(str: String): String = private fun capitalizeAsJavaClassName(str: String): String =
// NB use Locale.ENGLISH so that build is locale-independent. // NB `uppercase` uses Locale.ROOT and is locale-independent.
// See Javadoc on java.lang.String.toUpperCase() for more details. // See Javadoc on java.lang.String.toUpperCase() for more details.
if (Character.isJavaIdentifierStart(str[0])) if (Character.isJavaIdentifierStart(str[0]))
str.substring(0, 1).toUpperCase(Locale.ENGLISH) + str.substring(1) str.substring(0, 1).uppercase() + str.substring(1)
else else
"_$str" "_$str"
@@ -138,7 +138,7 @@ class FunctionInvokeDescriptor private constructor(
"E" -> "receiver" "E" -> "receiver"
else -> { else -> {
// Type parameter "P1" -> value parameter "p1", "P2" -> "p2", etc. // Type parameter "P1" -> value parameter "p1", "P2" -> "p2", etc.
typeParameterName.toLowerCase() typeParameterName.lowercase()
} }
} }
@@ -48,7 +48,7 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions {
assert(!field.name.startsWith("is")) { "Fields named is* are not supported here yet" } assert(!field.name.startsWith("is")) { "Fields named is* are not supported here yet" }
val value = property.getValue( val value = property.getValue(
this, this,
PropertyReference1Impl(DescriptorRendererOptionsImpl::class, field.name, "get" + field.name.capitalize()) PropertyReference1Impl(DescriptorRendererOptionsImpl::class, field.name, "get" + field.name.replaceFirstChar(Char::uppercaseChar))
) )
field.set(copy, copy.property(value)) field.set(copy, copy.property(value))
} }
@@ -28,7 +28,7 @@ fun String.decapitalizeSmartForCompiler(asciiOnly: Boolean = false): String {
if (isEmpty() || !isUpperCaseCharAt(0, asciiOnly)) return this if (isEmpty() || !isUpperCaseCharAt(0, asciiOnly)) return this
if (length == 1 || !isUpperCaseCharAt(1, asciiOnly)) { if (length == 1 || !isUpperCaseCharAt(1, asciiOnly)) {
return if (asciiOnly) decapitalizeAsciiOnly() else decapitalize() return if (asciiOnly) decapitalizeAsciiOnly() else replaceFirstChar(Char::lowercaseChar)
} }
val secondWordStart = (indices.firstOrNull { !isUpperCaseCharAt(it, asciiOnly) } ?: return toLowerCase(this, asciiOnly)) - 1 val secondWordStart = (indices.firstOrNull { !isUpperCaseCharAt(it, asciiOnly) } ?: return toLowerCase(this, asciiOnly)) - 1
@@ -98,18 +98,18 @@ private fun String.isLowerCaseCharAt(index: Int, asciiOnly: Boolean): Boolean {
} }
private fun toLowerCase(string: String, asciiOnly: Boolean): String { private fun toLowerCase(string: String, asciiOnly: Boolean): String {
return if (asciiOnly) string.toLowerCaseAsciiOnly() else string.toLowerCase() return if (asciiOnly) string.toLowerCaseAsciiOnly() else string.lowercase()
} }
private fun toUpperCase(string: String, asciiOnly: Boolean): String { private fun toUpperCase(string: String, asciiOnly: Boolean): String {
return if (asciiOnly) string.toUpperCaseAsciiOnly() else string.toUpperCase() return if (asciiOnly) string.toUpperCaseAsciiOnly() else string.uppercase()
} }
fun String.capitalizeAsciiOnly(): String { fun String.capitalizeAsciiOnly(): String {
if (isEmpty()) return this if (isEmpty()) return this
val c = this[0] val c = this[0]
return if (c in 'a'..'z') return if (c in 'a'..'z')
c.toUpperCase() + substring(1) c.uppercaseChar() + substring(1)
else else
this this
} }
@@ -118,7 +118,7 @@ fun String.decapitalizeAsciiOnly(): String {
if (isEmpty()) return this if (isEmpty()) return this
val c = this[0] val c = this[0]
return if (c in 'A'..'Z') return if (c in 'A'..'Z')
c.toLowerCase() + substring(1) c.lowercaseChar() + substring(1)
else else
this this
} }
@@ -126,7 +126,7 @@ fun String.decapitalizeAsciiOnly(): String {
fun String.toLowerCaseAsciiOnly(): String { fun String.toLowerCaseAsciiOnly(): String {
val builder = StringBuilder(length) val builder = StringBuilder(length)
for (c in this) { for (c in this) {
builder.append(if (c in 'A'..'Z') c.toLowerCase() else c) builder.append(if (c in 'A'..'Z') c.lowercaseChar() else c)
} }
return builder.toString() return builder.toString()
} }
@@ -134,7 +134,7 @@ fun String.toLowerCaseAsciiOnly(): String {
fun String.toUpperCaseAsciiOnly(): String { fun String.toUpperCaseAsciiOnly(): String {
val builder = StringBuilder(length) val builder = StringBuilder(length)
for (c in this) { for (c in this) {
builder.append(if (c in 'a'..'z') c.toUpperCase() else c) builder.append(if (c in 'a'..'z') c.uppercaseChar() else c)
} }
return builder.toString() return builder.toString()
} }
+1 -1
View File
@@ -188,7 +188,7 @@ private fun CallableDescriptor.getParametersTypes(): List<KotlinType> =
listOf((containingDeclaration as ClassDescriptor).defaultType) + listOf((containingDeclaration as ClassDescriptor).defaultType) +
valueParameters.map { it.type.makeNotNullable() } valueParameters.map { it.type.makeNotNullable() }
private fun KotlinType.asString(): String = typeName.toUpperCase() private fun KotlinType.asString(): String = typeName.uppercase()
private val KotlinType.typeName: String private val KotlinType.typeName: String
get(): String = constructor.declarationDescriptor!!.name.asString() get(): String = constructor.declarationDescriptor!!.name.asString()
@@ -46,10 +46,10 @@ open class SimpleTestMethodModel(
extractedName extractedName
} else { } else {
val relativePath = FileUtil.getRelativePath(rootDir, file.parentFile) val relativePath = FileUtil.getRelativePath(rootDir, file.parentFile)
relativePath + "-" + extractedName.capitalize() relativePath + "-" + extractedName.replaceFirstChar(Char::uppercaseChar)
} }
val ignored = skipIgnored && InTextDirectivesUtils.isIgnoredTarget(targetBackend, file) val ignored = skipIgnored && InTextDirectivesUtils.isIgnoredTarget(targetBackend, file)
return (if (ignored) "ignore" else "test") + escapeForJavaIdentifier(unescapedName).capitalize() return (if (ignored) "ignore" else "test") + escapeForJavaIdentifier(unescapedName).replaceFirstChar(Char::uppercaseChar)
} }
init { init {
@@ -31,7 +31,7 @@ object TestGeneratorUtil {
@JvmStatic @JvmStatic
fun fileNameToJavaIdentifier(file: File): String { fun fileNameToJavaIdentifier(file: File): String {
return escapeForJavaIdentifier(file.name).capitalize() return escapeForJavaIdentifier(file.name).replaceFirstChar(Char::uppercaseChar)
} }
} }
@@ -89,7 +89,7 @@ class GenerateProtoBufCompare {
} }
return (extensionPrefix + fieldDescriptor.name.javaName + (if (fieldDescriptor.isRepeated) "List" else "")) return (extensionPrefix + fieldDescriptor.name.javaName + (if (fieldDescriptor.isRepeated) "List" else ""))
.replace("[A-Z]".toRegex()) { "_" + it.value } .replace("[A-Z]".toRegex()) { "_" + it.value }
.toUpperCase() .uppercase()
} }
} }
@@ -236,7 +236,7 @@ class GenerateProtoBufCompare {
fun generateHashCodeForField(field: Descriptors.FieldDescriptor, p: Printer, isExtensionField: Boolean) { fun generateHashCodeForField(field: Descriptors.FieldDescriptor, p: Printer, isExtensionField: Boolean) {
val fieldName = field.name.javaName val fieldName = field.name.javaName
val capFieldName = fieldName.capitalize() val capFieldName = fieldName.replaceFirstChar(Char::uppercaseChar)
val outerClassName = field.file.options.javaOuterClassname.removePrefix("Debug") val outerClassName = field.file.options.javaOuterClassname.removePrefix("Debug")
val fullFieldName = "$outerClassName.$fieldName" val fullFieldName = "$outerClassName.$fieldName"
@@ -310,7 +310,7 @@ class GenerateProtoBufCompare {
val typeName = field.containingType.typeName val typeName = field.containingType.typeName
val fieldName = field.name.javaName val fieldName = field.name.javaName
val capFieldName = fieldName.capitalize() val capFieldName = fieldName.replaceFirstChar(Char::uppercaseChar)
val methodName = field.helperMethodName() val methodName = field.helperMethodName()
p.println() p.println()
@@ -357,7 +357,7 @@ class GenerateProtoBufCompare {
open inner class FieldGeneratorImpl(field: Descriptors.FieldDescriptor, p: Printer) : FieldGenerator(field, p) { open inner class FieldGeneratorImpl(field: Descriptors.FieldDescriptor, p: Printer) : FieldGenerator(field, p) {
val fieldName = field.name.javaName val fieldName = field.name.javaName
val capFieldName = fieldName.capitalize() val capFieldName = fieldName.replaceFirstChar(Char::uppercaseChar)
override fun printRepeatedField() { override fun printRepeatedField() {
repeatedFields.add(field) repeatedFields.add(field)
@@ -496,12 +496,12 @@ class GenerateProtoBufCompare {
val packageHeader = this.file.`package` val packageHeader = this.file.`package`
val descriptor = this.containingType val descriptor = this.containingType
val className = descriptor.fullName.removePrefix(packageHeader).replace(".", "") val className = descriptor.fullName.removePrefix(packageHeader).replace(".", "")
val capFieldName = this.name.javaName.capitalize() val capFieldName = this.name.javaName.replaceFirstChar(Char::uppercaseChar)
return "$CHECK_EQUALS_NAME$className$capFieldName" return "$CHECK_EQUALS_NAME$className$capFieldName"
} }
private val String.javaName: String private val String.javaName: String
get() = this.split("_").joinToString("") { it.capitalize() }.decapitalize() get() = this.split("_").joinToString("") { it.replaceFirstChar(Char::uppercaseChar) }.replaceFirstChar(Char::lowercaseChar)
} }
private fun Printer.printlnMultiline(string: String) { private fun Printer.printlnMultiline(string: String) {
@@ -158,7 +158,7 @@ object KDocTagCompletionProvider : CompletionProvider<CompletionParameters>() {
val resultWithPrefix = result.withPrefixMatcher(prefix) val resultWithPrefix = result.withPrefixMatcher(prefix)
KDocKnownTag.values().forEach { KDocKnownTag.values().forEach {
if (kdocOwner == null || it.isApplicable(kdocOwner)) { if (kdocOwner == null || it.isApplicable(kdocOwner)) {
resultWithPrefix.addElement(LookupElementBuilder.create("@" + it.name.toLowerCase(Locale.US))) resultWithPrefix.addElement(LookupElementBuilder.create("@" + it.name.lowercase()))
} }
} }
} }
@@ -68,7 +68,7 @@ class VariableOrParameterNameWithTypeCompletion(
prefixWords.indices.map { index -> if (index == 0) prefix else prefixWords.drop(index).joinToString("") } prefixWords.indices.map { index -> if (index == 0) prefix else prefixWords.drop(index).joinToString("") }
userPrefixes = nameSuggestionPrefixes.indices.map { prefixWords.take(it).joinToString("") } userPrefixes = nameSuggestionPrefixes.indices.map { prefixWords.take(it).joinToString("") }
classNamePrefixMatchers = nameSuggestionPrefixes.map { CamelHumpMatcher(it.capitalize(Locale.US), false) } classNamePrefixMatchers = nameSuggestionPrefixes.map { CamelHumpMatcher(it.replaceFirstChar(Char::uppercaseChar), false) }
} }
private val suggestionsByTypesAdded = HashSet<Type>() private val suggestionsByTypesAdded = HashSet<Type>()
@@ -4,4 +4,4 @@ fun foo(param: String) {
// EXIST: { itemText: "length", attributes: "" } // EXIST: { itemText: "length", attributes: "" }
// EXIST: { itemText: "hashCode", attributes: "" } // EXIST: { itemText: "hashCode", attributes: "" }
// EXIST: { itemText: "capitalize", attributes: "bold" } // EXIST: { itemText: "lowercase", attributes: "bold" }
@@ -62,8 +62,8 @@ class ProjectConfigurationCollector : ProjectUsagesCollector() {
val buildSystem = it.getBuildSystemType() val buildSystem = it.getBuildSystemType()
return when { return when {
buildSystem == BuildSystemType.JPS -> "JPS" buildSystem == BuildSystemType.JPS -> "JPS"
buildSystem.toString().toLowerCase().contains("maven") -> "Maven" buildSystem.toString().lowercase().contains("maven") -> "Maven"
buildSystem.toString().toLowerCase().contains("gradle") -> "Gradle" buildSystem.toString().lowercase().contains("gradle") -> "Gradle"
else -> "unknown" else -> "unknown"
} }
} }
@@ -31,7 +31,7 @@ abstract class AbstractFirLazyDeclarationResolveTest : KotlinLightCodeInsightFix
val ktFile = myFixture.configureByText(testDataFile.name, FileUtil.loadFile(testDataFile)) as KtFile val ktFile = myFixture.configureByText(testDataFile.name, FileUtil.loadFile(testDataFile)) as KtFile
val lazyDeclarations = ktFile.collectDescendantsOfType<KtDeclaration> { ktDeclaration -> !KtPsiUtil.isLocal(ktDeclaration) } val lazyDeclarations = ktFile.collectDescendantsOfType<KtDeclaration> { ktDeclaration -> !KtPsiUtil.isLocal(ktDeclaration) }
val declarationToResolve = lazyDeclarations.firstOrNull { it.name?.toLowerCase() == "resolveme" } val declarationToResolve = lazyDeclarations.firstOrNull { it.name?.lowercase() == "resolveme" }
?: error("declaration with name `resolveMe` was not found") ?: error("declaration with name `resolveMe` was not found")
resolveWithClearCaches(ktFile) { firModuleResolveState -> resolveWithClearCaches(ktFile) { firModuleResolveState ->
val rendered = declarationToResolve.withFirDeclaration( val rendered = declarationToResolve.withFirDeclaration(
@@ -100,7 +100,7 @@ private object FirToKtConversionCreator {
if (kClass.isSubclassOf(Collection::class)) { if (kClass.isSubclassOf(Collection::class)) {
val elementType = type.arguments.single().type ?: return HLIdParameterConversion val elementType = type.arguments.single().type ?: return HLIdParameterConversion
return HLMapParameterConversion( return HLMapParameterConversion(
parameterName = elementType.kClass.simpleName!!.decapitalize(), parameterName = elementType.kClass.simpleName!!.replaceFirstChar(Char::lowercaseChar),
mappingConversion = createConversion(elementType) mappingConversion = createConversion(elementType)
) )
} }
@@ -50,7 +50,7 @@ class KtFirCollectionLiteralReference(
}.associateWith { it.correspondingArrayOfCallFqName() } }.associateWith { it.correspondingArrayOfCallFqName() }
private fun ClassId.correspondingArrayOfCallFqName(): Name = private fun ClassId.correspondingArrayOfCallFqName(): Name =
Name.identifier("${shortClassName.identifier.decapitalize()}Of") Name.identifier("${shortClassName.identifier.replaceFirstChar(Char::lowercaseChar)}Of")
} }
} }
@@ -376,7 +376,7 @@ class KotlinBuildScriptManipulator(
findPlugin(pluginName) ?: addExpressionIfMissing("plugin(\"$pluginName\")") as? KtCallExpression findPlugin(pluginName) ?: addExpressionIfMissing("plugin(\"$pluginName\")") as? KtCallExpression
private fun KtFile.changeCoroutineConfiguration(coroutineOption: String): PsiElement? { private fun KtFile.changeCoroutineConfiguration(coroutineOption: String): PsiElement? {
val snippet = "experimental.coroutines = Coroutines.${coroutineOption.toUpperCase()}" val snippet = "experimental.coroutines = Coroutines.${coroutineOption.uppercase()}"
val kotlinBlock = getKotlinBlock() ?: return null val kotlinBlock = getKotlinBlock() ?: return null
addImportIfMissing("org.jetbrains.kotlin.gradle.dsl.Coroutines") addImportIfMissing("org.jetbrains.kotlin.gradle.dsl.Coroutines")
val statement = kotlinBlock.statements.find { it.text.startsWith("experimental.coroutines") } val statement = kotlinBlock.statements.find { it.text.startsWith("experimental.coroutines") }
@@ -50,7 +50,7 @@ class KotlinGradleFUSLogger : StartupActivity, DumbAware, Runnable {
// 2. the projectId should be stable and independent on IDE version // 2. the projectId should be stable and independent on IDE version
val presentableUrl = FileUtil.toSystemIndependentName(path) val presentableUrl = FileUtil.toSystemIndependentName(path)
val name = val name =
PathUtilRt.getFileName(presentableUrl).toLowerCase(Locale.US).removeSuffix(ProjectFileType.DOT_DEFAULT_EXTENSION) PathUtilRt.getFileName(presentableUrl).lowercase().removeSuffix(ProjectFileType.DOT_DEFAULT_EXTENSION)
val locationHash = Integer.toHexString((presentableUrl).hashCode()) val locationHash = Integer.toHexString((presentableUrl).hashCode())
val projectHash = val projectHash =
"${name.trimMiddle(name.length.coerceAtMost(254 - locationHash.length), useEllipsisSymbol = false)}.$locationHash" "${name.trimMiddle(name.length.coerceAtMost(254 - locationHash.length), useEllipsisSymbol = false)}.$locationHash"
@@ -85,7 +85,7 @@ class KotlinGradleFUSLogger : StartupActivity, DumbAware, Runnable {
val data = HashMap<String, String>() val data = HashMap<String, String>()
fun putIfNotNull(key: String, value: String?) { fun putIfNotNull(key: String, value: String?) {
if (value != null) { if (value != null) {
data[key.toLowerCase()] = value data[key.lowercase()] = value
} }
} }
@@ -127,7 +127,7 @@ class GradleTestRunConfigurationAndHighlightingTest : GradleImportingTestCase()
RunConfigurationsTags.SETTINGS -> settings.toString() RunConfigurationsTags.SETTINGS -> settings.toString()
} }
result += tag.name.toLowerCase() to renderedTagValue result += tag.name.lowercase() to renderedTagValue
} }
return result.joinToString { (tagName, tagValue) -> tagName + "=\"" + tagValue.replace("\"", "\\\"") + "\"" } return result.joinToString { (tagName, tagValue) -> tagName + "=\"" + tagValue.replace("\"", "\\\"") + "\"" }
@@ -74,7 +74,7 @@ class KotlinCompilerStartupActivity : StartupActivity {
override fun fileGenerated(outputRoot: String, relativePath: String) { override fun fileGenerated(outputRoot: String, relativePath: String) {
if (isUnitTestMode()) return if (isUnitTestMode()) return
val ext = FileUtilRt.getExtension(relativePath).toLowerCase() val ext = FileUtilRt.getExtension(relativePath).lowercase()
if (FILE_EXTS_WHICH_NEEDS_REFRESH.contains(ext)) { if (FILE_EXTS_WHICH_NEEDS_REFRESH.contains(ext)) {
val outFile = "$outputRoot/$relativePath" val outFile = "$outputRoot/$relativePath"
val virtualFile = LocalFileSystem.getInstance().findFileByPath(outFile) val virtualFile = LocalFileSystem.getInstance().findFileByPath(outFile)
@@ -218,7 +218,7 @@ class ModuleNewWizardFirstStep(wizard: IdeWizard) : WizardStep(wizard, Generatio
private fun suggestGroupId(): String { private fun suggestGroupId(): String {
val username = SystemProperties.getUserName() ?: return DEFAULT_GROUP_ID val username = SystemProperties.getUserName() ?: return DEFAULT_GROUP_ID
if (!username.matches("[\\w\\s]+".toRegex())) return DEFAULT_GROUP_ID if (!username.matches("[\\w\\s]+".toRegex())) return DEFAULT_GROUP_ID
val usernameAsGroupId = username.trim().toLowerCase(Locale.US).split("\\s+".toRegex()).joinToString(separator = ".") val usernameAsGroupId = username.trim().lowercase().split("\\s+".toRegex()).joinToString(separator = ".")
return "me.$usernameAsGroupId" return "me.$usernameAsGroupId"
} }
@@ -73,7 +73,7 @@ class ModulesEditorToolbarDecorator(
null -> "" null -> ""
} }
text = KotlinNewProjectWizardUIBundle.message("editor.modules.add", moduleKindTextToAdd.capitalize(Locale.US)) text = KotlinNewProjectWizardUIBundle.message("editor.modules.add", moduleKindTextToAdd.replaceFirstChar(Char::uppercaseChar))
} }
event.presentation.isEnabled event.presentation.isEnabled
} }
@@ -104,7 +104,7 @@ class ModulesEditorToolbarDecorator(
isEnabled = tree.selectedSettingItem is Module isEnabled = tree.selectedSettingItem is Module
text = KotlinNewProjectWizardUIBundle.message( text = KotlinNewProjectWizardUIBundle.message(
"editor.modules.remove.tooltip", "editor.modules.remove.tooltip",
selectedModuleKindText?.let { " ${it.capitalize(Locale.US)}" }.orEmpty() selectedModuleKindText?.let { " ${it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.US) else it.toString() }}" }.orEmpty()
) )
} }
event.presentation.isEnabled event.presentation.isEnabled
@@ -16,4 +16,5 @@
package org.jetbrains.eval4j.test package org.jetbrains.eval4j.test
fun getTestName(methodName: String) = if (methodName.startsWith("test")) methodName else "test${methodName.capitalize()}" fun getTestName(methodName: String) =
if (methodName.startsWith("test")) methodName else "test${methodName.replaceFirstChar(Char::uppercaseChar)}"
@@ -37,7 +37,7 @@ fun Location.isInKotlinSources(): Boolean {
} }
fun ReferenceType.isInKotlinSources(): Boolean { fun ReferenceType.isInKotlinSources(): Boolean {
val fileExtension = safeSourceName()?.substringAfterLast('.')?.toLowerCase() ?: "" val fileExtension = safeSourceName()?.substringAfterLast('.')?.lowercase() ?: ""
return fileExtension in KotlinFileTypeFactoryUtils.KOTLIN_EXTENSIONS || containsKotlinStrata() return fileExtension in KotlinFileTypeFactoryUtils.KOTLIN_EXTENSIONS || containsKotlinStrata()
} }
@@ -513,7 +513,7 @@ private fun reportError(codeFragment: KtCodeFragment, position: SourcePosition?,
) )
LOG.error( LOG.error(
"Cannot evaluate a code fragment of type " + codeFragment::class.java + ": " + message.decapitalize(), "Cannot evaluate a code fragment of type " + codeFragment::class.java + ": " + message.replaceFirstChar(Char::lowercaseChar),
throwable, throwable,
mergeAttachments(*attachments) mergeAttachments(*attachments)
) )
@@ -143,7 +143,7 @@ object DebuggerUtils {
} }
fun isKotlinSourceFile(fileName: String): Boolean { fun isKotlinSourceFile(fileName: String): Boolean {
val extension = FileUtilRt.getExtension(fileName).toLowerCase() val extension = FileUtilRt.getExtension(fileName).lowercase()
return extension in KotlinFileTypeFactoryUtils.KOTLIN_EXTENSIONS return extension in KotlinFileTypeFactoryUtils.KOTLIN_EXTENSIONS
} }
@@ -72,7 +72,7 @@ class KaptModelBuilderService : AbstractKotlinGradleModelBuilder() {
} }
val sourceSetName = compileTask.getSourceSetName() val sourceSetName = compileTask.getSourceSetName()
val isTest = sourceSetName.toLowerCase().endsWith("test") val isTest = sourceSetName.lowercase().endsWith("test")
val kaptGeneratedSourcesDir = getKaptDirectory("getKaptGeneratedSourcesDir", project, sourceSetName) val kaptGeneratedSourcesDir = getKaptDirectory("getKaptGeneratedSourcesDir", project, sourceSetName)
val kaptGeneratedClassesDir = getKaptDirectory("getKaptGeneratedClassesDir", project, sourceSetName) val kaptGeneratedClassesDir = getKaptDirectory("getKaptGeneratedClassesDir", project, sourceSetName)
@@ -91,7 +91,7 @@ class KaptModelBuilderService : AbstractKotlinGradleModelBuilder() {
val compilations = target.compilations ?: continue val compilations = target.compilations ?: continue
for (compilation in compilations) { for (compilation in compilations) {
val compileTask = compilation.getCompileKotlinTaskName(project) ?: continue val compileTask = compilation.getCompileKotlinTaskName(project) ?: continue
val moduleName = target.name + compilation.name.capitalize() val moduleName = target.name + compilation.name.replaceFirstChar(Char::uppercaseChar)
handleCompileTask(moduleName, compileTask) handleCompileTask(moduleName, compileTask)
} }
} }
+1 -1
View File
@@ -30,4 +30,4 @@ fun ClassLoader.loadClassOrNull(name: String): Class<*>? {
} }
fun compilationFullName(simpleName: String, classifier: String?) = fun compilationFullName(simpleName: String, classifier: String?) =
if (classifier != null) classifier + simpleName.capitalize() else simpleName if (classifier != null) classifier + simpleName.replaceFirstChar(Char::uppercaseChar) else simpleName
@@ -43,7 +43,7 @@ abstract class AbstractPerformanceCompletionHandlerTests(
protected open val statsPrefix = "completion" protected open val statsPrefix = "completion"
private fun stats(): Stats { private fun stats(): Stats {
val suffix = "${defaultCompletionType.toString().toLowerCase()}${if (note.isNotEmpty()) "-$note" else ""}" val suffix = "${defaultCompletionType.toString().lowercase()}${if (note.isNotEmpty()) "-$note" else ""}"
return statsMap.computeIfAbsent(suffix) { return statsMap.computeIfAbsent(suffix) {
Stats("$statsPrefix-$suffix") Stats("$statsPrefix-$suffix")
} }
@@ -65,7 +65,7 @@ class SuspiciousCollectionReassignmentInspection : AbstractKotlinInspection() {
else -> fixes.add(IntentionWrapper(ReplaceWithOrdinaryAssignmentIntention(), binaryExpression.containingKtFile)) else -> fixes.add(IntentionWrapper(ReplaceWithOrdinaryAssignmentIntention(), binaryExpression.containingKtFile))
} }
val typeText = leftDefaultType.toString().takeWhile { it != '<' }.toLowerCase() val typeText = leftDefaultType.toString().takeWhile { it != '<' }.lowercase()
val operationReference = binaryExpression.operationReference val operationReference = binaryExpression.operationReference
holder.registerProblem( holder.registerProblem(
operationReference, operationReference,
@@ -183,7 +183,7 @@ class ConvertFunctionTypeParameterToReceiverIntention : SelfTargetingRangeIntent
if (callable !is PsiNamedElement) continue if (callable !is PsiNamedElement) continue
if (!checkModifiable(callable)) { if (!checkModifiable(callable)) {
val renderedCallable = RefactoringUIUtil.getDescription(callable, true).capitalize() val renderedCallable = RefactoringUIUtil.getDescription(callable, true).replaceFirstChar(Char::uppercaseChar)
conflicts.putValue(callable, KotlinBundle.message("can.t.modify.0", renderedCallable)) conflicts.putValue(callable, KotlinBundle.message("can.t.modify.0", renderedCallable))
} }
@@ -120,7 +120,7 @@ class ConvertFunctionTypeReceiverToParameterIntention : SelfTargetingRangeIntent
if (callable !is KtFunction) continue if (callable !is KtFunction) continue
if (!checkModifiable(callable)) { if (!checkModifiable(callable)) {
val renderedCallable = RefactoringUIUtil.getDescription(callable, true).capitalize() val renderedCallable = RefactoringUIUtil.getDescription(callable, true).replaceFirstChar(Char::uppercaseChar)
conflicts.putValue(callable, KotlinBundle.message("can.t.modify.0", renderedCallable)) conflicts.putValue(callable, KotlinBundle.message("can.t.modify.0", renderedCallable))
} }
@@ -103,7 +103,7 @@ class ConvertPropertyToFunctionIntention : SelfTargetingIntention<KtProperty>(
if (callable !is PsiNamedElement) continue if (callable !is PsiNamedElement) continue
if (!checkModifiable(callable)) { if (!checkModifiable(callable)) {
val renderedCallable = RefactoringUIUtil.getDescription(callable, true).capitalize() val renderedCallable = RefactoringUIUtil.getDescription(callable, true).replaceFirstChar(Char::uppercaseChar)
conflicts.putValue(callable, KotlinBundle.message("can.t.modify.0", renderedCallable)) conflicts.putValue(callable, KotlinBundle.message("can.t.modify.0", renderedCallable))
} }
@@ -281,7 +281,7 @@ class MoveMemberToCompanionObjectIntention : SelfTargetingRangeIntention<KtNamed
return return
} }
val description = RefactoringUIUtil.getDescription(element, false).capitalize() val description = RefactoringUIUtil.getDescription(element, false).replaceFirstChar(Char::uppercaseChar)
if (HierarchySearchRequest(element, element.useScope, false).searchOverriders().any()) { if (HierarchySearchRequest(element, element.useScope, false).searchOverriders().any()) {
return CommonRefactoringUtil.showErrorHint( return CommonRefactoringUtil.showErrorHint(
@@ -23,7 +23,7 @@ class AddArrayOfTypeFix(expression: KtExpression, expectedType: KotlinType) : Ko
"arrayOf" "arrayOf"
} else { } else {
val typeName = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(expectedType) val typeName = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(expectedType)
"${typeName.decapitalize(Locale.US)}Of" "${typeName.replaceFirstChar(Char::lowercaseChar)}Of"
} }
@@ -55,7 +55,7 @@ enum class ClassKind(@NonNls val keyword: String, @Nls val description: String)
DEFAULT("", "") // Used as a placeholder and must be replaced with one of the kinds above DEFAULT("", "") // Used as a placeholder and must be replaced with one of the kinds above
} }
fun ClassKind.toIdeaClassKind() = IdeaClassKind { this@toIdeaClassKind.description.capitalize() } fun ClassKind.toIdeaClassKind() = IdeaClassKind { this@toIdeaClassKind.description.replaceFirstChar(Char::uppercaseChar) }
val ClassKind.actionPriority: IntentionActionPriority val ClassKind.actionPriority: IntentionActionPriority
get() = if (this == ANNOTATION_CLASS) IntentionActionPriority.LOW else IntentionActionPriority.NORMAL get() = if (this == ANNOTATION_CLASS) IntentionActionPriority.LOW else IntentionActionPriority.NORMAL
@@ -185,7 +185,7 @@ open class CreateClassFromUsageFix<E : KtElement> protected constructor(
val defaultPackageFqName = file.packageFqName val defaultPackageFqName = file.packageFqName
val dialog = object : CreateKotlinClassDialog( val dialog = object : CreateKotlinClassDialog(
file.project, file.project,
KotlinBundle.message("create.0", ideaClassKind.description.capitalize()), KotlinBundle.message("create.0", ideaClassKind.description.replaceFirstChar(Char::uppercaseChar)),
className, className,
defaultPackageFqName.asString(), defaultPackageFqName.asString(),
ideaClassKind, ideaClassKind,
@@ -789,7 +789,7 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor {
val prefix = if (declaration != null) RefactoringUIUtil.getDescription(declaration, true) else originalRef.text val prefix = if (declaration != null) RefactoringUIUtil.getDescription(declaration, true) else originalRef.text
result.putValue( result.putValue(
originalRef, originalRef,
KotlinBundle.message("text.0.will.no.longer.be.accessible.after.signature.change", prefix.capitalize()) KotlinBundle.message("text.0.will.no.longer.be.accessible.after.signature.change", prefix.replaceFirstChar(Char::uppercaseChar))
) )
} }
} }
@@ -52,7 +52,7 @@ abstract class AbstractKotlinInlineDialog(
override fun getNameLabelText(): String { override fun getNameLabelText(): String {
val occurrencesString = occurrencesString?.let { " - $it" } ?: "" val occurrencesString = occurrencesString?.let { " - $it" } ?: ""
return "${kind.capitalize()} ${callable.nameAsSafeName} $occurrencesString" return "${kind.replaceFirstChar(Char::uppercaseChar)} ${callable.nameAsSafeName} $occurrencesString"
} }
private fun getInlineText(verb: String) = KotlinBundle.message( private fun getInlineText(verb: String) = KotlinBundle.message(
@@ -74,21 +74,22 @@ class KotlinInplacePropertyIntroducer(
if (availableTargets.size > 1) { if (availableTargets.size > 1) {
addPanelControl( addPanelControl(
ControlWrapper { ControlWrapper {
val propertyKindComboBox = with(JComboBox(availableTargets.map { it.targetName.capitalize() }.toTypedArray())) { val propertyKindComboBox =
addPopupMenuListener( with(JComboBox(availableTargets.map { it.targetName.replaceFirstChar(Char::uppercaseChar) }.toTypedArray())) {
object : PopupMenuListenerAdapter() { addPopupMenuListener(
override fun popupMenuWillBecomeInvisible(e: PopupMenuEvent?) { object : PopupMenuListenerAdapter() {
ApplicationManager.getApplication().invokeLater { override fun popupMenuWillBecomeInvisible(e: PopupMenuEvent?) {
currentTarget = availableTargets[selectedIndex] ApplicationManager.getApplication().invokeLater {
currentTarget = availableTargets[selectedIndex]
}
} }
} }
} )
)
selectedIndex = availableTargets.indexOf(currentTarget) selectedIndex = availableTargets.indexOf(currentTarget)
this this
} }
val propertyKindLabel = JLabel(KotlinBundle.message("label.text.introduce.as")) val propertyKindLabel = JLabel(KotlinBundle.message("label.text.introduce.as"))
propertyKindLabel.labelFor = propertyKindComboBox propertyKindLabel.labelFor = propertyKindComboBox
@@ -233,7 +233,7 @@ fun reportDeclarationConflict(
declaration: PsiElement, declaration: PsiElement,
message: (renderedDeclaration: String) -> String message: (renderedDeclaration: String) -> String
) { ) {
conflicts.putValue(declaration, message(RefactoringUIUtil.getDescription(declaration, true).capitalize())) conflicts.putValue(declaration, message(RefactoringUIUtil.getDescription(declaration, true).replaceFirstChar(Char::uppercaseChar)))
} }
fun <T, E : PsiElement> getPsiElementPopup( fun <T, E : PsiElement> getPsiElementPopup(
@@ -27,7 +27,7 @@ internal class MoveFilesWithDeclarationsViewDescriptor(
"move.single.element.elements.header", "move.single.element.elements.header",
UsageViewUtil.getType(myElementsToMove[0]), UsageViewUtil.getType(myElementsToMove[0]),
newParent.virtualFile.presentableUrl newParent.virtualFile.presentableUrl
).capitalize() ).replaceFirstChar(Char::uppercaseChar)
myCodeReferencesText = KotlinBundle.message( myCodeReferencesText = KotlinBundle.message(
"text.references.in.code.to.0.1.and.its.declarations", "text.references.in.code.to.0.1.and.its.declarations",
UsageViewUtil.getType(myElementsToMove[0]), UsageViewUtil.getType(myElementsToMove[0]),
@@ -416,7 +416,7 @@ class MoveConflictChecker(
render(container), render(container),
render(referencedElement) render(referencedElement)
) )
conflicts.putValue(element, message.capitalize()) conflicts.putValue(element, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
} }
@@ -494,7 +494,7 @@ class MoveConflictChecker(
render(declaration), render(declaration),
render(target) render(target)
) )
conflicts.putValue(refExpr, message.capitalize()) conflicts.putValue(refExpr, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
} }
@@ -527,7 +527,7 @@ class MoveConflictChecker(
render(container), render(container),
render(memberToCheck) render(memberToCheck)
) )
conflicts.putValue(element, message.capitalize()) conflicts.putValue(element, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
} }
@@ -573,7 +573,8 @@ class MoveConflictChecker(
val message = if (elementToMove == rootClass) { val message = if (elementToMove == rootClass) {
KotlinBundle.message("text.sealed.class.0.must.be.moved.with.all.its.subclasses", rootClass.name.toString()) KotlinBundle.message("text.sealed.class.0.must.be.moved.with.all.its.subclasses", rootClass.name.toString())
} else { } else {
val type = ElementDescriptionUtil.getElementDescription(elementToMove, UsageViewTypeLocation.INSTANCE).capitalize() val type = ElementDescriptionUtil.getElementDescription(elementToMove, UsageViewTypeLocation.INSTANCE)
.replaceFirstChar(Char::uppercaseChar)
KotlinBundle.message( KotlinBundle.message(
"text.0.1.must.be.moved.with.sealed.parent.class.and.all.its.subclasses", "text.0.1.must.be.moved.with.sealed.parent.class.and.all.its.subclasses",
type, type,
@@ -93,7 +93,7 @@ internal fun checkVisibilityInAbstractedMembers(
val memberText = memberDescriptor.renderForConflicts() val memberText = memberDescriptor.renderForConflicts()
val targetText = targetDescriptor.renderForConflicts() val targetText = targetDescriptor.renderForConflicts()
val message = KotlinBundle.message("text.0.uses.1.which.will.not.be.accessible.from.subclass", memberText, targetText) val message = KotlinBundle.message("text.0.uses.1.which.will.not.be.accessible.from.subclass", memberText, targetText)
conflicts.putValue(target, message.capitalize()) conflicts.putValue(target, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
} }
@@ -148,7 +148,7 @@ private fun KotlinPullUpData.checkClashWithSuperDeclaration(
if (member is KtParameter) { if (member is KtParameter) {
if (((targetClass as? KtClass)?.primaryConstructorParameters ?: emptyList()).any { it.name == member.name }) { if (((targetClass as? KtClass)?.primaryConstructorParameters ?: emptyList()).any { it.name == member.name }) {
conflicts.putValue(member, message.capitalize()) conflicts.putValue(member, message.replaceFirstChar(Char::uppercaseChar))
} }
return return
} }
@@ -158,7 +158,7 @@ private fun KotlinPullUpData.checkClashWithSuperDeclaration(
val clashingSuper = getClashingMemberInTargetClass(memberDescriptor) ?: return val clashingSuper = getClashingMemberInTargetClass(memberDescriptor) ?: return
if (clashingSuper.modality == Modality.ABSTRACT) return if (clashingSuper.modality == Modality.ABSTRACT) return
if (clashingSuper.kind != CallableMemberDescriptor.Kind.DECLARATION) return if (clashingSuper.kind != CallableMemberDescriptor.Kind.DECLARATION) return
conflicts.putValue(member, message.capitalize()) conflicts.putValue(member, message.replaceFirstChar(Char::uppercaseChar))
} }
private fun PsiClass.isSourceOrTarget(data: KotlinPullUpData): Boolean { private fun PsiClass.isSourceOrTarget(data: KotlinPullUpData): Boolean {
@@ -198,7 +198,7 @@ private fun KotlinPullUpData.checkAccidentalOverrides(
memberDescriptor.renderForConflicts(), memberDescriptor.renderForConflicts(),
it.resolveToDescriptorWrapperAware(resolutionFacade).renderForConflicts() it.resolveToDescriptorWrapperAware(resolutionFacade).renderForConflicts()
) )
conflicts.putValue(clashingMember, message.capitalize()) conflicts.putValue(clashingMember, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
} }
@@ -211,7 +211,7 @@ private fun KotlinPullUpData.checkInnerClassToInterface(
) { ) {
if (isInterfaceTarget && memberDescriptor is ClassDescriptor && memberDescriptor.isInner) { if (isInterfaceTarget && memberDescriptor is ClassDescriptor && memberDescriptor.isInner) {
val message = KotlinBundle.message("text.inner.class.0.cannot.be.moved.to.intefrace", memberDescriptor.renderForConflicts()) val message = KotlinBundle.message("text.inner.class.0.cannot.be.moved.to.intefrace", memberDescriptor.renderForConflicts())
conflicts.putValue(member, message.capitalize()) conflicts.putValue(member, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
@@ -231,7 +231,7 @@ private fun KotlinPullUpData.checkVisibility(
memberDescriptor.renderForConflicts(), memberDescriptor.renderForConflicts(),
targetDescriptor.renderForConflicts() targetDescriptor.renderForConflicts()
) )
conflicts.putValue(target, message.capitalize()) conflicts.putValue(target, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
@@ -44,7 +44,8 @@ class KotlinPushDownHandler : AbstractPullPushMembersHandler(
private fun reportFinalClassOrObject(project: Project, editor: Editor?, classOrObject: KtClassOrObject) { private fun reportFinalClassOrObject(project: Project, editor: Editor?, classOrObject: KtClassOrObject) {
val message = RefactoringBundle.getCannotRefactorMessage( val message = RefactoringBundle.getCannotRefactorMessage(
KotlinBundle.message("text.class.0.is.final", RefactoringUIUtil.getDescription(classOrObject, false)).capitalize() KotlinBundle.message("text.class.0.is.final", RefactoringUIUtil.getDescription(classOrObject, false))
.replaceFirstChar(Char::uppercaseChar)
) )
CommonRefactoringUtil.showErrorHint(project, editor, message, PULL_MEMBERS_UP, HelpID.MEMBERS_PULL_UP) CommonRefactoringUtil.showErrorHint(project, editor, message, PULL_MEMBERS_UP, HelpID.MEMBERS_PULL_UP)
} }
@@ -100,7 +100,7 @@ class KotlinPushDownProcessor(
val usages = refUsages.get() ?: UsageInfo.EMPTY_ARRAY val usages = refUsages.get() ?: UsageInfo.EMPTY_ARRAY
if (usages.isEmpty()) { if (usages.isEmpty()) {
val message = KotlinBundle.message("text.0.have.no.inheritors.warning", context.sourceClassDescriptor.renderForConflicts()) val message = KotlinBundle.message("text.0.have.no.inheritors.warning", context.sourceClassDescriptor.renderForConflicts())
val answer = Messages.showYesNoDialog(message.capitalize(), PUSH_MEMBERS_DOWN, Messages.getWarningIcon()) val answer = Messages.showYesNoDialog(message.replaceFirstChar(Char::uppercaseChar), PUSH_MEMBERS_DOWN, Messages.getWarningIcon())
if (answer == Messages.NO) return false if (answer == Messages.NO) return false
} }
@@ -88,7 +88,7 @@ private fun checkConflicts(
targetClassDescriptor.renderForConflicts(), targetClassDescriptor.renderForConflicts(),
context.sourceClassDescriptor.renderForConflicts() context.sourceClassDescriptor.renderForConflicts()
) )
conflicts.putValue(targetClass, message.capitalize()) conflicts.putValue(targetClass, message.replaceFirstChar(Char::uppercaseChar))
} }
for (member in membersToPush) { for (member in membersToPush) {
@@ -146,7 +146,7 @@ private fun checkMemberClashing(
targetClassDescriptor.renderForConflicts(), targetClassDescriptor.renderForConflicts(),
CommonRefactoringUtil.htmlEmphasize(member.name ?: "") CommonRefactoringUtil.htmlEmphasize(member.name ?: "")
) )
conflicts.putValue(it, message.capitalize()) conflicts.putValue(it, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
} }
@@ -217,7 +217,7 @@ private fun checkVisibility(
targetDescriptor.renderForConflicts(), targetDescriptor.renderForConflicts(),
targetClassDescriptor.renderForConflicts() targetClassDescriptor.renderForConflicts()
) )
conflicts.putValue(target, message.capitalize()) conflicts.putValue(target, message.replaceFirstChar(Char::uppercaseChar))
} }
} }
@@ -114,7 +114,7 @@ class RenameKotlinPropertyProcessor : RenameKotlinPsiProcessor() {
result: MutableList<UsageInfo> result: MutableList<UsageInfo>
) { ) {
fun reportAccidentalOverride(candidate: PsiNamedElement) { fun reportAccidentalOverride(candidate: PsiNamedElement) {
val what = UsageViewUtil.getType(declaration).capitalize() val what = UsageViewUtil.getType(declaration).replaceFirstChar(Char::uppercaseChar)
val withWhat = candidate.renderDescription() val withWhat = candidate.renderDescription()
val where = candidate.representativeContainer()?.renderDescription() ?: return val where = candidate.representativeContainer()?.renderDescription() ?: return
val message = KotlinBundle.message("text.0.will.clash.with.existing.1.in.2", what, withWhat, where) val message = KotlinBundle.message("text.0.will.clash.with.existing.1.in.2", what, withWhat, where)
@@ -166,7 +166,7 @@ internal fun checkRedeclarations(
if (overloadChecker != null && overloadChecker.isOverloadable(descriptor, candidateDescriptor)) continue if (overloadChecker != null && overloadChecker.isOverloadable(descriptor, candidateDescriptor)) continue
val what = candidate.renderDescription() val what = candidate.renderDescription()
val where = candidate.representativeContainer()?.renderDescription() ?: continue val where = candidate.representativeContainer()?.renderDescription() ?: continue
val message = KotlinBundle.message("text.0.already.declared.in.1", what, where).capitalize() val message = KotlinBundle.message("text.0.already.declared.in.1", what, where).replaceFirstChar(Char::uppercaseChar)
result += BasicUnresolvableCollisionUsageInfo(candidate, candidate, message) result += BasicUnresolvableCollisionUsageInfo(candidate, candidate, message)
} }
} }
@@ -197,7 +197,7 @@ fun reportShadowing(
"text.0.will.be.shadowed.by.1", "text.0.will.be.shadowed.by.1",
declaration.renderDescription(), declaration.renderDescription(),
candidate.renderDescription() candidate.renderDescription()
).capitalize() ).replaceFirstChar(Char::uppercaseChar)
result += BasicUnresolvableCollisionUsageInfo(refElement, elementToBindUsageInfoTo, message) result += BasicUnresolvableCollisionUsageInfo(refElement, elementToBindUsageInfoTo, message)
} }
@@ -20,7 +20,7 @@ abstract class AbstractConfigureKotlinInTempDirTest : AbstractConfigureKotlinTes
FileUtil.copyDir(File(projectRoot), tempDir) FileUtil.copyDir(File(projectRoot), tempDir)
val kotlinRuntime = File(tempDir, "lib/kotlin-stdlib.jar") val kotlinRuntime = File(tempDir, "lib/kotlin-stdlib.jar")
if (getTestName(true).toLowerCase().contains("latestruntime") && kotlinRuntime.exists()) { if (getTestName(true).lowercase().contains("latestruntime") && kotlinRuntime.exists()) {
ForTestCompileRuntime.runtimeJarForTests().copyTo(kotlinRuntime, overwrite = true) ForTestCompileRuntime.runtimeJarForTests().copyTo(kotlinRuntime, overwrite = true)
} }
@@ -67,7 +67,7 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase(), Q
} }
override fun getProjectDescriptor(): LightProjectDescriptor = override fun getProjectDescriptor(): LightProjectDescriptor =
if ("createfromusage" in testDataPath.toLowerCase()) { if ("createfromusage" in testDataPath.lowercase()) {
KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
} else { } else {
super.getProjectDescriptor() super.getProjectDescriptor()
@@ -139,7 +139,7 @@ abstract class AbstractResolveModeComparisonTest : KotlinLightCodeInsightFixture
val modes = mark.modes val modes = mark.modes
val modesRepresentation = val modesRepresentation =
if (modes.size == RESOLVE_MODES.size) "All" if (modes.size == RESOLVE_MODES.size) "All"
else modes.joinToString { it.toString().toLowerCase().capitalize() } else modes.joinToString { it.toString().lowercase().replaceFirstChar(Char::uppercaseChar) }
"/*$modesRepresentation (${mark.ordinal})*/" "/*$modesRepresentation (${mark.ordinal})*/"
} }
is Mark.NotAnalyzed -> { is Mark.NotAnalyzed -> {
@@ -131,7 +131,7 @@ abstract class AbstractScriptConfigurationTest : KotlinCompletionTestCase() {
} }
// If script is inside module // If script is inside module
if (module != null && mainScriptFile.parentFile.name.toLowerCase().contains("module")) { if (module != null && mainScriptFile.parentFile.name.lowercase().contains("module")) {
module.addDependency( module.addDependency(
projectLibrary( projectLibrary(
"script-runtime", "script-runtime",
@@ -295,7 +295,7 @@ class ClassLiteralExpression(val type: Type): Expression() {
fun createArrayInitializerExpression(arrayType: ArrayType, initializers: List<Expression>, needExplicitType: Boolean = true) : MethodCallExpression { fun createArrayInitializerExpression(arrayType: ArrayType, initializers: List<Expression>, needExplicitType: Boolean = true) : MethodCallExpression {
val elementType = arrayType.elementType val elementType = arrayType.elementType
val createArrayFunction = when { val createArrayFunction = when {
elementType is PrimitiveType -> (elementType.toNotNullType().canonicalCode() + "ArrayOf").decapitalize(Locale.US) elementType is PrimitiveType -> (elementType.toNotNullType().canonicalCode() + "ArrayOf").replaceFirstChar(Char::lowercaseChar)
needExplicitType -> "arrayOf<" + arrayType.elementType.canonicalCode() + ">" needExplicitType -> "arrayOf<" + arrayType.elementType.canonicalCode() + ">"
else -> "arrayOf" else -> "arrayOf"
} }
@@ -276,7 +276,7 @@ abstract class AbstractIncrementalJpsTest(
} }
if (!makeOverallResult.makeFailed) { if (!makeOverallResult.makeFailed) {
if (checkDumpsCaseInsensitively && rebuildResult.mappingsDump?.toLowerCase() == makeOverallResult.mappingsDump?.toLowerCase()) { if (checkDumpsCaseInsensitively && rebuildResult.mappingsDump?.lowercase() == makeOverallResult.mappingsDump?.lowercase()) {
// do nothing // do nothing
} else { } else {
TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump) TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump)
@@ -29,7 +29,7 @@ fun actualizeMppJpsIncTestCaseDirs(rootDir: String, dir: String) {
} }
class MppJpsIncTestsGenerator(val txt: ModulesTxt, val testCaseDirProvider: (TestCase) -> File) { class MppJpsIncTestsGenerator(val txt: ModulesTxt, val testCaseDirProvider: (TestCase) -> File) {
val ModulesTxt.Module.capitalName get() = name.capitalize() val ModulesTxt.Module.capitalName get() = name.replaceFirstChar(Char::uppercaseChar)
val testCases: List<TestCase> val testCases: List<TestCase>
@@ -308,7 +308,7 @@ class MppJpsIncTestsGenerator(val txt: ModulesTxt, val testCaseDirProvider: (Tes
protected fun serviceKtFile(module: ModulesTxt.Module, fileNameSuffix: String = ""): File { protected fun serviceKtFile(module: ModulesTxt.Module, fileNameSuffix: String = ""): File {
val suffix = val suffix =
if (module.isCommonModule) "${module.serviceName}Header" if (module.isCommonModule) "${module.serviceName}Header"
else "${module.name.capitalize()}${module.contentsSettings.serviceNameSuffix}Impl" else "${module.name.replaceFirstChar(Char::uppercaseChar)}${module.contentsSettings.serviceNameSuffix}Impl"
return File(dir, "${module.indexedName}_service$suffix.kt$fileNameSuffix") return File(dir, "${module.indexedName}_service$suffix.kt$fileNameSuffix")
} }
@@ -47,7 +47,7 @@ fun Context.isObjectFunction(function: JsExpression, functionName: String): Bool
fun Context.isKotlinFunction(function: JsExpression, name: String): Boolean { fun Context.isKotlinFunction(function: JsExpression, name: String): Boolean {
if (function !is JsNameRef || function.ident != name) return false if (function !is JsNameRef || function.ident != name) return false
val receiver = (function.qualifier as? JsNameRef)?.name ?: return false val receiver = (function.qualifier as? JsNameRef)?.name ?: return false
return receiver in nodes && receiver.ident.toLowerCase(Locale.US) == "kotlin" return receiver in nodes && receiver.ident.lowercase() == "kotlin"
} }
fun isSpecialFunction(expr: JsExpression, specialFunction: SpecialFunction): Boolean = fun isSpecialFunction(expr: JsExpression, specialFunction: SpecialFunction): Boolean =
@@ -18,7 +18,7 @@ enum class ErrorTolerancePolicy(val allowSyntaxErrors: Boolean, val allowSemanti
val DEFAULT = NONE val DEFAULT = NONE
fun resolvePolicy(key: String): ErrorTolerancePolicy { fun resolvePolicy(key: String): ErrorTolerancePolicy {
return when (key.toUpperCase(Locale.US)) { return when (key.uppercase()) {
"NONE" -> NONE "NONE" -> NONE
"SEMANTIC" -> SEMANTIC "SEMANTIC" -> SEMANTIC
"SYNTAX", "ALL" -> ALL "SYNTAX", "ALL" -> ALL
@@ -311,7 +311,10 @@ private class TestDataBuilder {
.replace(KEYWORD_MARKER, keywordWithEscapeIfNeed) .replace(KEYWORD_MARKER, keywordWithEscapeIfNeed)
val fileName = "${suite.name.decapitalize()}${case.name.capitalize()}${keyword.capitalize()}.kt" val decapitalizedSuiteName = suite.name.replaceFirstChar(Char::lowercaseChar)
val capitalizedCaseName = case.name.replaceFirstChar(Char::uppercaseChar)
val capitalizedKeyword = keyword.replaceFirstChar(Char::uppercaseChar)
val fileName = "$decapitalizedSuiteName$capitalizedCaseName$capitalizedKeyword.kt"
val testDataFile = File(testDataDirPath + "/" + fileName) val testDataFile = File(testDataDirPath + "/" + fileName)
@@ -109,7 +109,7 @@ object ArrayFIF : CompositeFIF() {
} }
private val PrimitiveType.lowerCaseName private val PrimitiveType.lowerCaseName
get() = typeName.asString().toLowerCase(Locale.US) get() = typeName.asString().lowercase()
fun getTag(descriptor: CallableDescriptor, config: JsConfig): String? { fun getTag(descriptor: CallableDescriptor, config: JsConfig): String? {
if (descriptor !is ConstructorDescriptor) return null if (descriptor !is ConstructorDescriptor) return null

Some files were not shown because too many files have changed in this diff Show More