Migrate compiler, idea and others to new case conversion api
This commit is contained in:
+1
-1
@@ -42,4 +42,4 @@ private fun CharSequence.trimTrailingWhitespacesAndAddNewlineAtEOF(): String =
|
||||
|
||||
|
||||
private val UPPER_CASE_CHARS = Regex("[A-Z]+")
|
||||
fun String.replaceCamelCaseWithDashedLowerCase() = replace(UPPER_CASE_CHARS) { "-" + it.value.toLowerCase() }
|
||||
fun String.replaceCamelCaseWithDashedLowerCase() = replace(UPPER_CASE_CHARS) { "-" + it.value.lowercase() }
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class Directories(
|
||||
// compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/FileSystemUtils.kt
|
||||
// which in turn is based on: http://www.code4copy.com/java/post/detecting-os-type-in-java
|
||||
private val os: OSKind
|
||||
get() = getProperty("os.name")?.toLowerCase(Locale.US).let { name ->
|
||||
get() = getProperty("os.name")?.lowercase().let { name ->
|
||||
when {
|
||||
name == null -> OSKind.Unknown
|
||||
name.startsWith("windows") -> OSKind.Windows
|
||||
|
||||
@@ -310,7 +310,7 @@ private fun printType(flags: Flags, output: (String) -> Unit): KmTypeVisitor =
|
||||
printType(flags) { argumentTypeString ->
|
||||
arguments += buildString {
|
||||
if (variance != KmVariance.INVARIANT) {
|
||||
append(variance.name.toLowerCase(Locale.US)).append(" ")
|
||||
append(variance.name.lowercase()).append(" ")
|
||||
}
|
||||
append(argumentTypeString)
|
||||
}
|
||||
@@ -400,7 +400,7 @@ private fun printTypeParameter(
|
||||
append("@").append(renderAnnotation(annotation)).append(" ")
|
||||
}
|
||||
if (variance != KmVariance.INVARIANT) {
|
||||
append(variance.name.toLowerCase(Locale.US)).append(" ")
|
||||
append(variance.name.lowercase()).append(" ")
|
||||
}
|
||||
append("T#$id")
|
||||
if (settings.isVerbose) {
|
||||
|
||||
+6
-2
@@ -28,7 +28,7 @@ fun <V> inValidatorContext(validator: Reader.(V) -> SettingValidator<V>) =
|
||||
object StringValidators {
|
||||
fun shouldNotBeBlank(name: String) = settingValidator { value: String ->
|
||||
if (value.isBlank()) ValidationResult.ValidationError(
|
||||
KotlinNewProjectWizardBundle.message("validation.should.not.be.blank", name.capitalize())
|
||||
KotlinNewProjectWizardBundle.message("validation.should.not.be.blank", name.replaceFirstChar(Char::uppercaseChar))
|
||||
)
|
||||
else ValidationResult.OK
|
||||
}
|
||||
@@ -41,7 +41,11 @@ object StringValidators {
|
||||
?.let { chars -> KotlinNewProjectWizardBundle.message("validation.identifier.additional.symbols", chars) }
|
||||
.orEmpty()
|
||||
ValidationResult.ValidationError(
|
||||
KotlinNewProjectWizardBundle.message("validation.identifier", name.capitalize(), allowedExtraSymbolsStringified)
|
||||
KotlinNewProjectWizardBundle.message(
|
||||
"validation.identifier",
|
||||
name.replaceFirstChar(Char::uppercaseChar),
|
||||
allowedExtraSymbolsStringified
|
||||
)
|
||||
)
|
||||
} else ValidationResult.OK
|
||||
}
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ object StringSettingType : SettingType<String>() {
|
||||
neededAtPhase: GenerationPhase
|
||||
) : SettingBuilder<String, StringSettingType>(path, title, neededAtPhase) {
|
||||
fun shouldNotBeBlank() {
|
||||
validate(StringValidators.shouldNotBeBlank(title.capitalize()))
|
||||
validate(StringValidators.shouldNotBeBlank(title.replaceFirstChar(Char::uppercaseChar)))
|
||||
}
|
||||
|
||||
override val type = StringSettingType
|
||||
@@ -202,7 +202,7 @@ object PathSettingType : SettingType<Path>() {
|
||||
ValidationResult.ValidationError(
|
||||
KotlinNewProjectWizardBundle.message(
|
||||
"validation.should.not.be.blank",
|
||||
title.capitalize()
|
||||
title.replaceFirstChar(Char::uppercaseChar)
|
||||
)
|
||||
)
|
||||
else ValidationResult.OK
|
||||
@@ -213,7 +213,7 @@ object PathSettingType : SettingType<Path>() {
|
||||
if (isUnitTestMode) return@validate ValidationResult.OK
|
||||
if (!Files.exists(pathValue))
|
||||
ValidationResult.ValidationError(
|
||||
KotlinNewProjectWizardBundle.message("validation.file.should.exists", title.capitalize())
|
||||
KotlinNewProjectWizardBundle.message("validation.file.should.exists", title.replaceFirstChar(Char::uppercaseChar))
|
||||
)
|
||||
else ValidationResult.OK
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ data class ConfiguratorNotFoundError(val id: String) : Error() {
|
||||
|
||||
data class ValidationError(val validationMessage: String) : Error() {
|
||||
override val message: String
|
||||
get() = validationMessage.capitalize()
|
||||
get() = validationMessage.replaceFirstChar(Char::uppercaseChar)
|
||||
}
|
||||
|
||||
data class ProjectImportingError(val kotlinVersion: String, @Nls val reason: String) : Error() {
|
||||
|
||||
+4
-4
@@ -54,10 +54,10 @@ abstract class KotlinVersionProviderService : WizardService {
|
||||
|
||||
|
||||
private fun getKotlinVersionKind(version: Version) = when {
|
||||
"eap" in version.toString().toLowerCase() -> KotlinVersionKind.EAP
|
||||
"rc" in version.toString().toLowerCase() -> KotlinVersionKind.EAP
|
||||
"dev" in version.toString().toLowerCase() -> KotlinVersionKind.DEV
|
||||
"m" in version.toString().toLowerCase() -> KotlinVersionKind.M
|
||||
"eap" in version.toString().lowercase() -> KotlinVersionKind.EAP
|
||||
"rc" in version.toString().lowercase() -> KotlinVersionKind.EAP
|
||||
"dev" in version.toString().lowercase() -> KotlinVersionKind.DEV
|
||||
"m" in version.toString().lowercase() -> KotlinVersionKind.M
|
||||
else -> KotlinVersionKind.STABLE
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ fun SourcesetType.toDependencyType() = when (this) {
|
||||
|
||||
fun DependencyType.getGradleName(kind: DependencyKind) = when (this) {
|
||||
DependencyType.MAIN -> kind.text
|
||||
DependencyType.TEST -> "test${kind.text.capitalize(Locale.US)}"
|
||||
DependencyType.TEST -> "test${kind.text.replaceFirstChar(Char::uppercaseChar)}"
|
||||
}
|
||||
|
||||
data class ArtifactBasedLibraryDependencyIR(
|
||||
|
||||
+1
-1
@@ -56,4 +56,4 @@ data class MultiplatformSourcesetIR(
|
||||
}
|
||||
|
||||
val MultiplatformSourcesetIR.sourcesetName
|
||||
get() = targetName + sourcesetType.name.capitalize(Locale.US)
|
||||
get() = targetName + sourcesetType.name.replaceFirstChar(Char::uppercaseChar)
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ interface NativeTargetConfigurator : TargetConfigurator {
|
||||
class RealNativeTargetConfigurator private constructor(
|
||||
override val moduleSubType: ModuleSubType
|
||||
) : NativeTargetConfigurator, SimpleTargetConfigurator {
|
||||
override val text: String = moduleSubType.name.capitalize(Locale.US)
|
||||
override val text: String = moduleSubType.name.replaceFirstChar(Char::uppercaseChar)
|
||||
override val isDesktopTarget: Boolean
|
||||
get() = moduleSubType.isNativeDesktop
|
||||
|
||||
|
||||
+1
-1
@@ -319,7 +319,7 @@ private fun pathForFileInTarget(
|
||||
sourcesetType: SourcesetType,
|
||||
) = mppModulePath /
|
||||
Defaults.SRC_DIR /
|
||||
"${target.name}${sourcesetType.name.capitalize(Locale.US)}" /
|
||||
"${target.name}${sourcesetType.name.replaceFirstChar(Char::uppercaseChar)}" /
|
||||
mppModule.configurator.kotlinDirectoryName /
|
||||
javaPackage?.asPath() /
|
||||
filename
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
|
||||
else -> ValidationResult.ValidationError(
|
||||
KotlinNewProjectWizardBundle.message(
|
||||
"plugin.buildsystem.setting.type.error.wrong.project.kind",
|
||||
projectKind.shortName.capitalize(),
|
||||
projectKind.shortName.replaceFirstChar(Char::uppercaseChar),
|
||||
buildSystemType.fullText
|
||||
)
|
||||
)
|
||||
|
||||
+1
-1
@@ -266,7 +266,7 @@ class ModulesToIRsConverter(
|
||||
val (moduleDependencies) = createModuleDependencies(target)
|
||||
mutateProjectStructureByModuleConfigurator(target, modulePath)
|
||||
val sourcesetss = target.sourcesets.map { sourceset ->
|
||||
val sourcesetName = target.name + sourceset.sourcesetType.name.capitalize(Locale.US)
|
||||
val sourcesetName = target.name + sourceset.sourcesetType.name.replaceFirstChar(Char::uppercaseChar)
|
||||
MultiplatformSourcesetIR(
|
||||
sourceset.sourcesetType,
|
||||
modulePath / Defaults.SRC_DIR / sourcesetName,
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ class TemplatesPlugin(context: Context) : Plugin(context) {
|
||||
is SrcFilePath -> moduleConfigurator.kotlinDirectoryName
|
||||
is ResourcesFilePath -> moduleConfigurator.resourcesDirectoryName
|
||||
}
|
||||
SRC_DIR / "${module.name}${filePath.sourcesetType.name.capitalize(Locale.US)}" / directory
|
||||
SRC_DIR / "${module.name}${filePath.sourcesetType.name.replaceFirstChar(Char::uppercaseChar)}" / directory
|
||||
}
|
||||
is FakeMultiplatformModuleIR -> error("Not supported for FakeMultiplatformModuleIR")
|
||||
}
|
||||
|
||||
+2
-2
@@ -128,7 +128,7 @@ class Module(
|
||||
?: return@map ValidationResult.ValidationError(
|
||||
KotlinNewProjectWizardBundle.message(
|
||||
"validation.should.not.be.blank",
|
||||
setting.title.capitalize()
|
||||
setting.title.replaceFirstChar(Char::uppercaseChar)
|
||||
)
|
||||
)
|
||||
(setting.validator as SettingValidator<Any>).validate(this@settingValidator, value)
|
||||
@@ -145,7 +145,7 @@ class Module(
|
||||
?: return@map ValidationResult.ValidationError(
|
||||
KotlinNewProjectWizardBundle.message(
|
||||
"validation.should.not.be.blank",
|
||||
setting.title.capitalize()
|
||||
setting.title.replaceFirstChar(Char::uppercaseChar)
|
||||
)
|
||||
)
|
||||
(setting.validator as SettingValidator<Any>).validate(this@settingValidator, value)
|
||||
|
||||
+2
-2
@@ -111,8 +111,8 @@ enum class KtorServerEngine(val engineName: String, val dependencyName: String)
|
||||
);
|
||||
|
||||
override val text: String
|
||||
get() = engineName.capitalize()
|
||||
get() = engineName.replaceFirstChar(Char::uppercaseChar)
|
||||
|
||||
val import: String
|
||||
get() = "io.ktor.server.${engineName.decapitalize(Locale.US)}.${engineName.capitalize(Locale.US)}"
|
||||
get() = "io.ktor.server.${engineName.replaceFirstChar(Char::lowercaseChar)}.${engineName.replaceFirstChar(Char::uppercaseChar)}"
|
||||
}
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
|
||||
|
||||
|
||||
private fun Reader.createDefaultSettings() = mapOf(
|
||||
"projectName" to StructurePlugin.name.settingValue.capitalize(Locale.US)
|
||||
"projectName" to StructurePlugin.name.settingValue.replaceFirstChar(Char::uppercaseChar)
|
||||
)
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
|
||||
Reference in New Issue
Block a user