diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ComponentStorage.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ComponentStorage.kt index f6e419474..b5b286848 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ComponentStorage.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ComponentStorage.kt @@ -154,7 +154,7 @@ internal abstract class AbstractConcurrentComponentStorage : ComponentStorage { throwable: Throwable, ) { throw ExtensionException( - "Exception while executing extension ${extension.kClassQualifiedNameOrTip} provided by plugin '${plugin.name}', registered for ${this.type.qualifiedName}", + "Exception while executing extension '${extension.kClassQualifiedNameOrTip}' provided by plugin '${plugin.name}', registered for '${this.extensionType.qualifiedName}'", throwable ) } diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionException.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionException.kt new file mode 100644 index 000000000..3b4025c94 --- /dev/null +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionException.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2020 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * + * https://github.com/mamoe/mirai/blob/master/LICENSE + */ + +@file:Suppress("unused") + +package net.mamoe.mirai.console.extension + +/** + * 在调用一个 extension 时遇到的异常. + */ +public open class ExtensionException : RuntimeException { + public constructor() : super() + public constructor(message: String?) : super(message) + public constructor(message: String?, cause: Throwable?) : super(message, cause) + public constructor(cause: Throwable?) : super(cause) +} \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt index efe62a988..da9d0ff80 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/extension/ExtensionPoint.kt @@ -11,52 +11,20 @@ package net.mamoe.mirai.console.extension -import net.mamoe.mirai.console.plugin.loader.PluginLoader -import net.mamoe.mirai.console.util.ConsoleExperimentalApi import kotlin.reflect.KClass -import kotlin.reflect.full.isSubclassOf -@ConsoleExperimentalApi +/** + * 由 [Extension] 的 `companion` 实现. + */ public interface ExtensionPoint { - public val type: KClass - - public companion object { - @JvmStatic - @JvmSynthetic - @ConsoleExperimentalApi - public inline fun ExtensionPoint<*>.isFor(exactType: Boolean = false): Boolean { - return if (exactType) { - T::class == type - } else T::class.isSubclassOf(type) - } - } + public val extensionType: KClass } -@ConsoleExperimentalApi -public interface SingletonExtensionPoint> : ExtensionPoint - -/** - * 表示一个扩展点 - */ -@ConsoleExperimentalApi public open class AbstractExtensionPoint( - @ConsoleExperimentalApi - public override val type: KClass, + public override val extensionType: KClass, ) : ExtensionPoint - /** - * 在调用一个 extension 时遇到的异常. - * - * @see PluginLoader.load - * @see PluginLoader.enable - * @see PluginLoader.disable - * @see PluginLoader.description + * 表示一个 [SingletonExtension] 的 [ExtensionPoint] */ -@ConsoleExperimentalApi -public open class ExtensionException : RuntimeException { - public constructor() : super() - public constructor(message: String?) : super(message) - public constructor(message: String?, cause: Throwable?) : super(message, cause) - public constructor(cause: Throwable?) : super(cause) -} \ No newline at end of file +public interface SingletonExtensionPoint> : ExtensionPoint \ No newline at end of file