From ab5cbcd5468822154d84711f56abaa27192c6458 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 19 Nov 2020 09:23:51 +0800 Subject: [PATCH] 1.0 Review: documentation and misc improvements --- .../src/command/descriptor/CommandValueArgumentParser.kt | 9 +++++++++ backend/mirai-console/src/data/ValueDescription.kt | 4 +++- backend/mirai-console/src/data/ValueName.kt | 2 +- .../src/internal/extension/ComponentStorageInternal.kt | 2 +- .../src/logging/AbstractLoggerController.kt | 2 +- .../permission/PermissionRegistryConflictException.kt | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/backend/mirai-console/src/command/descriptor/CommandValueArgumentParser.kt b/backend/mirai-console/src/command/descriptor/CommandValueArgumentParser.kt index e8d4e67b3..c09f7d87a 100644 --- a/backend/mirai-console/src/command/descriptor/CommandValueArgumentParser.kt +++ b/backend/mirai-console/src/command/descriptor/CommandValueArgumentParser.kt @@ -16,7 +16,10 @@ import net.mamoe.mirai.console.command.CommandManager import net.mamoe.mirai.console.command.CommandSender import net.mamoe.mirai.console.command.CompositeCommand import net.mamoe.mirai.console.command.SimpleCommand +import net.mamoe.mirai.console.command.descriptor.CommandValueArgumentParser.Companion.map import net.mamoe.mirai.console.command.descriptor.CommandValueArgumentParser.Companion.parse +import net.mamoe.mirai.console.permission.PermissionId +import net.mamoe.mirai.console.permission.PermitteeId import net.mamoe.mirai.contact.* import net.mamoe.mirai.message.data.* import kotlin.contracts.InvocationKind @@ -45,6 +48,9 @@ import kotlin.contracts.contract * - [User]: [ExistingUserValueArgumentParser] * - [Contact]: [ExistingContactValueArgumentParser] * + * - [PermitteeId]: [PermitteeIdValueArgumentParser] + * - [PermissionId]: [PermissionIdValueArgumentParser] + * * * @see SimpleCommand 简单指令 * @see CompositeCommand 复合指令 @@ -143,6 +149,9 @@ public abstract class AbstractCommandValueArgumentParser : CommandValue } } +/** + * @see CommandValueArgumentParser.map + */ public class MappingCommandValueArgumentParser( private val original: CommandValueArgumentParser, private val mapper: MappingCommandValueArgumentParser.(T) -> R, diff --git a/backend/mirai-console/src/data/ValueDescription.kt b/backend/mirai-console/src/data/ValueDescription.kt index aeeaaf9c8..4960ff6d8 100644 --- a/backend/mirai-console/src/data/ValueDescription.kt +++ b/backend/mirai-console/src/data/ValueDescription.kt @@ -31,13 +31,15 @@ import kotlinx.serialization.SerialInfo * map: * a: b * ``` + * + * @see net.mamoe.yamlkt.Comment */ @SerialInfo @Target(AnnotationTarget.PROPERTY, AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) public annotation class ValueDescription( /** - * 将会被 [String.trimIndent] 处理. + * 将会被 [String.trimIndent] 处理 */ val value: String, ) \ No newline at end of file diff --git a/backend/mirai-console/src/data/ValueName.kt b/backend/mirai-console/src/data/ValueName.kt index 17f101429..00452736b 100644 --- a/backend/mirai-console/src/data/ValueName.kt +++ b/backend/mirai-console/src/data/ValueName.kt @@ -23,7 +23,7 @@ package net.mamoe.mirai.console.data * 将被保存为配置 (YAML 作为示例): * ```yaml * AccountPluginData: - * map: + * info: * a: b * ``` * diff --git a/backend/mirai-console/src/internal/extension/ComponentStorageInternal.kt b/backend/mirai-console/src/internal/extension/ComponentStorageInternal.kt index 6f4af7bd2..dedf18192 100644 --- a/backend/mirai-console/src/internal/extension/ComponentStorageInternal.kt +++ b/backend/mirai-console/src/internal/extension/ComponentStorageInternal.kt @@ -154,7 +154,7 @@ internal abstract class AbstractConcurrentComponentStorage : ComponentStorage { internal inline fun ExtensionPoint.useExtensions(block: (extension: T, plugin: Plugin?) -> Unit): Unit = withExtensions(block) - val instances: MutableMap, MutableSet>> = ConcurrentHashMap() + private val instances: MutableMap, MutableSet>> = ConcurrentHashMap() override fun contribute( extensionPoint: ExtensionPoint, plugin: Plugin, diff --git a/backend/mirai-console/src/logging/AbstractLoggerController.kt b/backend/mirai-console/src/logging/AbstractLoggerController.kt index 3d4725990..a3105bcac 100644 --- a/backend/mirai-console/src/logging/AbstractLoggerController.kt +++ b/backend/mirai-console/src/logging/AbstractLoggerController.kt @@ -18,7 +18,7 @@ public abstract class AbstractLoggerController : LoggerController { protected open fun shouldLog( priority: LogPriority, - settings: LogPriority + settings: LogPriority, ): Boolean = settings <= priority protected abstract fun getPriority(identity: String?): LogPriority diff --git a/backend/mirai-console/src/permission/PermissionRegistryConflictException.kt b/backend/mirai-console/src/permission/PermissionRegistryConflictException.kt index 0378a924f..a288d9886 100644 --- a/backend/mirai-console/src/permission/PermissionRegistryConflictException.kt +++ b/backend/mirai-console/src/permission/PermissionRegistryConflictException.kt @@ -17,4 +17,4 @@ package net.mamoe.mirai.console.permission public class PermissionRegistryConflictException( public val newInstance: Permission, public val existingInstance: Permission, -) : Exception("Conflicted Permission registry. new: $newInstance, existing: $existingInstance") \ No newline at end of file +) : Exception("Conflicting Permission registry. new: $newInstance, existing: $existingInstance") \ No newline at end of file