Minor: reformat + clean warnings in org.jetbrains.kotlin.generators.arguments.test

This commit is contained in:
Nikolay Krasko
2021-12-13 13:38:00 +03:00
committed by teamcity
parent e733aa21d5
commit 00f0978b1d
2 changed files with 89 additions and 68 deletions
@@ -47,9 +47,11 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
val commonInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinCommonToolOptions") val commonInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinCommonToolOptions")
val commonOptions = gradleOptions<CommonToolArguments>() val commonOptions = gradleOptions<CommonToolArguments>()
val additionalOptions = gradleOptions<AdditionalGradleProperties>() val additionalOptions = gradleOptions<AdditionalGradleProperties>()
withPrinterToFile(File(apiSrcDir, commonInterfaceFqName)) { withPrinterToFile(file(apiSrcDir, commonInterfaceFqName)) {
generateInterface(commonInterfaceFqName, generateInterface(
commonOptions + additionalOptions) commonInterfaceFqName,
commonOptions + additionalOptions
)
} }
println("### Attributes common for JVM, JS, and JS DCE\n") println("### Attributes common for JVM, JS, and JS DCE\n")
@@ -57,10 +59,12 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
val commonCompilerInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions") val commonCompilerInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions")
val commonCompilerOptions = gradleOptions<CommonCompilerArguments>() val commonCompilerOptions = gradleOptions<CommonCompilerArguments>()
withPrinterToFile(File(apiSrcDir, commonCompilerInterfaceFqName)) { withPrinterToFile(file(apiSrcDir, commonCompilerInterfaceFqName)) {
generateInterface(commonCompilerInterfaceFqName, generateInterface(
commonCompilerInterfaceFqName,
commonCompilerOptions, commonCompilerOptions,
parentType = commonInterfaceFqName) parentType = commonInterfaceFqName
)
} }
println("\n### Attributes common for JVM and JS\n") println("\n### Attributes common for JVM and JS\n")
@@ -69,20 +73,24 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
// generate jvm interface // generate jvm interface
val jvmInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions") val jvmInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions")
val jvmOptions = gradleOptions<K2JVMCompilerArguments>() val jvmOptions = gradleOptions<K2JVMCompilerArguments>()
withPrinterToFile(File(srcDir, jvmInterfaceFqName)) { withPrinterToFile(file(srcDir, jvmInterfaceFqName)) {
generateInterface(jvmInterfaceFqName, generateInterface(
jvmInterfaceFqName,
jvmOptions, jvmOptions,
parentType = commonCompilerInterfaceFqName) parentType = commonCompilerInterfaceFqName
)
} }
// generate jvm impl // generate jvm impl
val k2JvmCompilerArgumentsFqName = FqName(K2JVMCompilerArguments::class.qualifiedName!!) val k2JvmCompilerArgumentsFqName = FqName(K2JVMCompilerArguments::class.qualifiedName!!)
val jvmImplFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsBase") val jvmImplFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsBase")
withPrinterToFile(File(srcDir, jvmImplFqName)) { withPrinterToFile(file(srcDir, jvmImplFqName)) {
generateImpl(jvmImplFqName, generateImpl(
jvmImplFqName,
jvmInterfaceFqName, jvmInterfaceFqName,
k2JvmCompilerArgumentsFqName, k2JvmCompilerArgumentsFqName,
commonOptions + commonCompilerOptions + jvmOptions) commonOptions + commonCompilerOptions + jvmOptions
)
} }
println("\n### Attributes specific for JVM\n") println("\n### Attributes specific for JVM\n")
@@ -91,19 +99,23 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
// generate js interface // generate js interface
val jsInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions") val jsInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions")
val jsOptions = gradleOptions<K2JSCompilerArguments>() val jsOptions = gradleOptions<K2JSCompilerArguments>()
withPrinterToFile(File(srcDir, jsInterfaceFqName)) { withPrinterToFile(file(srcDir, jsInterfaceFqName)) {
generateInterface(jsInterfaceFqName, generateInterface(
jsInterfaceFqName,
jsOptions, jsOptions,
parentType = commonCompilerInterfaceFqName) parentType = commonCompilerInterfaceFqName
)
} }
val k2JsCompilerArgumentsFqName = FqName(K2JSCompilerArguments::class.qualifiedName!!) val k2JsCompilerArgumentsFqName = FqName(K2JSCompilerArguments::class.qualifiedName!!)
val jsImplFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsOptionsBase") val jsImplFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsOptionsBase")
withPrinterToFile(File(srcDir, jsImplFqName)) { withPrinterToFile(file(srcDir, jsImplFqName)) {
generateImpl(jsImplFqName, generateImpl(
jsImplFqName,
jsInterfaceFqName, jsInterfaceFqName,
k2JsCompilerArgumentsFqName, k2JsCompilerArgumentsFqName,
commonOptions + commonCompilerOptions + jsOptions) commonOptions + commonCompilerOptions + jsOptions
)
} }
println("\n### Attributes specific for JS\n") println("\n### Attributes specific for JS\n")
@@ -112,37 +124,45 @@ fun generateKotlinGradleOptions(withPrinterToFile: (targetFile: File, Printer.()
// generate JS DCE interface and implementation // generate JS DCE interface and implementation
val jsDceInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsDceOptions") val jsDceInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsDceOptions")
val jsDceOptions = gradleOptions<K2JSDceArguments>() val jsDceOptions = gradleOptions<K2JSDceArguments>()
withPrinterToFile(File(srcDir, jsDceInterfaceFqName)) { withPrinterToFile(file(srcDir, jsDceInterfaceFqName)) {
generateInterface(jsDceInterfaceFqName, generateInterface(
jsDceInterfaceFqName,
jsDceOptions, jsDceOptions,
parentType = commonInterfaceFqName) parentType = commonInterfaceFqName
)
} }
val k2JsDceArgumentsFqName = FqName(K2JSDceArguments::class.qualifiedName!!) val k2JsDceArgumentsFqName = FqName(K2JSDceArguments::class.qualifiedName!!)
val jsDceImplFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsDceOptionsBase") val jsDceImplFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinJsDceOptionsBase")
withPrinterToFile(File(srcDir, jsDceImplFqName)) { withPrinterToFile(file(srcDir, jsDceImplFqName)) {
generateImpl(jsDceImplFqName, generateImpl(
jsDceImplFqName,
jsDceInterfaceFqName, jsDceInterfaceFqName,
k2JsDceArgumentsFqName, k2JsDceArgumentsFqName,
commonOptions + jsDceOptions) commonOptions + jsDceOptions
)
} }
// generate multiplatform common interface and implementation // generate multiplatform common interface and implementation
val multiplatformCommonInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformCommonOptions") val multiplatformCommonInterfaceFqName = FqName("org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformCommonOptions")
val multiplatformCommonOptions = gradleOptions<K2MetadataCompilerArguments>() val multiplatformCommonOptions = gradleOptions<K2MetadataCompilerArguments>()
withPrinterToFile(File(srcDir, multiplatformCommonInterfaceFqName)) { withPrinterToFile(file(srcDir, multiplatformCommonInterfaceFqName)) {
generateInterface(multiplatformCommonInterfaceFqName, generateInterface(
multiplatformCommonInterfaceFqName,
multiplatformCommonOptions, multiplatformCommonOptions,
parentType = commonCompilerInterfaceFqName) parentType = commonCompilerInterfaceFqName
)
} }
val k2metadataCompilerArgumentsFqName = FqName(K2MetadataCompilerArguments::class.qualifiedName!!) val k2metadataCompilerArgumentsFqName = FqName(K2MetadataCompilerArguments::class.qualifiedName!!)
val multiplatformCommonImplFqName = FqName(multiplatformCommonInterfaceFqName.asString() + "Base") val multiplatformCommonImplFqName = FqName(multiplatformCommonInterfaceFqName.asString() + "Base")
withPrinterToFile(File(srcDir, multiplatformCommonImplFqName)) { withPrinterToFile(file(srcDir, multiplatformCommonImplFqName)) {
generateImpl(multiplatformCommonImplFqName, generateImpl(
multiplatformCommonImplFqName,
multiplatformCommonInterfaceFqName, multiplatformCommonInterfaceFqName,
k2metadataCompilerArgumentsFqName, k2metadataCompilerArgumentsFqName,
commonOptions + commonCompilerOptions + multiplatformCommonOptions) commonOptions + commonCompilerOptions + multiplatformCommonOptions
)
} }
} }
@@ -172,7 +192,7 @@ private inline fun <reified T : Any> List<KProperty1<T, *>>.filterToBeDeleted()
private inline fun <reified T : Any> gradleOptions(): List<KProperty1<T, *>> = private inline fun <reified T : Any> gradleOptions(): List<KProperty1<T, *>> =
T::class.declaredMemberProperties.filter { it.findAnnotation<GradleOption>() != null }.filterToBeDeleted().sortedBy { it.name } T::class.declaredMemberProperties.filter { it.findAnnotation<GradleOption>() != null }.filterToBeDeleted().sortedBy { it.name }
private fun File(baseDir: File, fqName: FqName): File { private fun file(baseDir: File, fqName: FqName): File {
val fileRelativePath = fqName.asString().replace(".", "/") + ".kt" val fileRelativePath = fqName.asString().replace(".", "/") + ".kt"
return File(baseDir, fileRelativePath) return File(baseDir, fileRelativePath)
} }
@@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
@file:Suppress("PackageDirectoryMismatch")
package org.jetbrains.kotlin.generators.arguments.test package org.jetbrains.kotlin.generators.arguments.test
import junit.framework.TestCase import junit.framework.TestCase