From 6619c0b05acff1d9b8c83b7707d2988dec29c1e2 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 22 May 2020 20:07:47 +0800 Subject: [PATCH] Rearrange implementations --- .../mamoe/mirai/console/codegen/ValueImplCodegen.kt | 2 +- .../net/mamoe/mirai/console/codegen/ValuesCodegen.kt | 2 +- .../kotlin/net/mamoe/mirai/console/setting/Setting.kt | 1 + .../kotlin/net/mamoe/mirai/console/setting/_Setting.kt | 2 ++ .../mirai/console/setting/{ => internal}/_ValueImpl.kt | 8 ++++++-- .../setting/{utils.kt => internal/collectionUtil.kt} | 2 +- .../setting/{Internal.kt => internal/internal.kt} | 10 ++++++++-- .../{ValueImpl.kt => internal/internalValueImpl.kt} | 3 ++- 8 files changed, 22 insertions(+), 8 deletions(-) rename backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/{ => internal}/_ValueImpl.kt (99%) rename backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/{utils.kt => internal/collectionUtil.kt} (99%) rename backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/{Internal.kt => internal/internal.kt} (94%) rename backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/{ValueImpl.kt => internal/internalValueImpl.kt} (99%) diff --git a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt index a054f8857..d7f912fb5 100644 --- a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt +++ b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValueImplCodegen.kt @@ -16,7 +16,7 @@ import java.io.File fun main() { println(File("").absolutePath) // default project base dir - File("backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt").apply { + File("backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt").apply { createNewFile() }.writeText(buildString { appendln(COPYRIGHT) diff --git a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValuesCodegen.kt b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValuesCodegen.kt index 3b3d095c9..35cdf17b0 100644 --- a/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValuesCodegen.kt +++ b/backend/codegen/src/main/kotlin/net/mamoe/mirai/console/codegen/ValuesCodegen.kt @@ -74,7 +74,7 @@ fun genPublicApi() = buildString { appendln( """ /** - * !!! These primitive types are auto-generated by backend/codegen/src/main/kotlin/net.mamoe.mirai.console.codegen.ValuesCodegen.kt + * !!! This file is auto-generated by backend/codegen/src/main/kotlin/net.mamoe.mirai.console.codegen.ValuesCodegen.kt * !!! for better performance * !!! DO NOT MODIFY THIS FILE MANUALLY */ diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/Setting.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/Setting.kt index 6282aa90b..5aeb0f2e3 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/Setting.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/Setting.kt @@ -12,6 +12,7 @@ package net.mamoe.mirai.console.setting import kotlinx.serialization.KSerializer +import net.mamoe.mirai.console.setting.internal.SettingImpl import net.mamoe.mirai.utils.MiraiExperimentalAPI import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_Setting.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_Setting.kt index 2f4b80a48..32966a2a3 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_Setting.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_Setting.kt @@ -10,6 +10,8 @@ package net.mamoe.mirai.console.setting +import net.mamoe.mirai.console.setting.internal.valueImpl + /** * !!! This file is auto-generated by backend/codegen/src/kotlin/net.mamoe.mirai.console.codegen.SettingValueUseSiteCodegen.kt * !!! DO NOT MODIFY THIS FILE MANUALLY diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt similarity index 99% rename from backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt rename to backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt index 8382b8532..ded01b9ef 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/_ValueImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/_ValueImpl.kt @@ -7,13 +7,14 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.console.setting +package net.mamoe.mirai.console.setting.internal import kotlinx.serialization.Decoder import kotlinx.serialization.Encoder import kotlinx.serialization.KSerializer import kotlinx.serialization.SerialDescriptor import kotlinx.serialization.builtins.* +import net.mamoe.mirai.console.setting.* /** @@ -1353,7 +1354,10 @@ internal fun Setting.valueImpl(default: T): Value { } override fun serialize(encoder: Encoder, value: T) { - internalValue.updaterSerializer.serialize(encoder, SettingSerializerMark) + internalValue.updaterSerializer.serialize( + encoder, + SettingSerializerMark + ) } } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/utils.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/collectionUtil.kt similarity index 99% rename from backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/utils.kt rename to backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/collectionUtil.kt index 0f069db89..c686d2fdb 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/utils.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/collectionUtil.kt @@ -7,7 +7,7 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.console.setting +package net.mamoe.mirai.console.setting.internal import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.serializer diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/Internal.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/internal.kt similarity index 94% rename from backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/Internal.kt rename to backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/internal.kt index 0be4020e5..84a9c1b72 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/Internal.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/internal.kt @@ -7,11 +7,14 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.console.setting +package net.mamoe.mirai.console.setting.internal import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.serializer +import net.mamoe.mirai.console.setting.SerialName +import net.mamoe.mirai.console.setting.Setting +import net.mamoe.mirai.console.setting.Value import net.mamoe.yamlkt.Yaml import net.mamoe.yamlkt.YamlConfiguration import kotlin.reflect.KProperty @@ -41,7 +44,10 @@ internal abstract class SettingImpl { } override fun serialize(encoder: Encoder, value: Setting) { - this@SettingImpl.updaterSerializer.serialize(encoder, SettingSerializerMark) + this@SettingImpl.updaterSerializer.serialize( + encoder, + SettingSerializerMark + ) } } } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/ValueImpl.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/internalValueImpl.kt similarity index 99% rename from backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/ValueImpl.kt rename to backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/internalValueImpl.kt index 10660113f..23d9e4efb 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/ValueImpl.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/setting/internal/internalValueImpl.kt @@ -7,11 +7,12 @@ * https://github.com/mamoe/mirai/blob/master/LICENSE */ -package net.mamoe.mirai.console.setting +package net.mamoe.mirai.console.setting.internal import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.SetSerializer +import net.mamoe.mirai.console.setting.* import net.mamoe.yamlkt.YamlDynamicSerializer import kotlin.reflect.KClass import kotlin.reflect.full.createInstance