Skip to content

Commit

Permalink
fix(spring-boot-starter): 修复可重复注解无法读取的问题;以及其他小调整
Browse files Browse the repository at this point in the history
fix #540
  • Loading branch information
ForteScarlet committed Dec 13, 2022
1 parent 4e1b767 commit c243ee5
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 121 deletions.
4 changes: 2 additions & 2 deletions libs.versions.toml
@@ -1,7 +1,7 @@
[versions]
kotlinx-coroutines = "1.6.4"
kotlinx-serialization = "1.4.0"
spring-boot = "2.7.2"
spring-boot = "2.7.6"
openjdk-jmh = "1.35"
forte-di = "0.0.3"
forte-annotationTool = "0.6.3"
Expand Down Expand Up @@ -72,4 +72,4 @@ ktor-server-netty = { group = "io.ktor", name = "ktor-server-netty", version.ref

# Lincheck
# https://kotlinlang.org/docs/lincheck-guide.html#associate-compiler-tasks
kotlinx-lincheck = "org.jetbrains.kotlinx:lincheck:2.15"
kotlinx-lincheck = "org.jetbrains.kotlinx:lincheck:2.15"
@@ -1,17 +1,14 @@
/*
* Copyright (c) 2021-2022 ForteScarlet <ForteScarlet@163.com>
* Copyright (c) 2021-2022 ForteScarlet <ForteScarlet@163.com>
*
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x ) 的一部分。
*
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
*
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x 、simbot3 等) 的一部分。
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
*/

package love.forte.simboot.annotation
Expand Down Expand Up @@ -78,7 +75,6 @@ import kotlin.reflect.KClass
*
*/
@Retention(AnnotationRetention.RUNTIME)
@Repeatable
@JvmRepeatable(Filters::class)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
@MustBeDocumented
Expand All @@ -88,21 +84,21 @@ public annotation class Filter(
* 如果此属性为空,则相当于不生效。
*/
val value: String = "",

/**
* 当 [value] 匹配的目标([EventListenerProcessingContext.textContent][love.forte.simbot.event.EventListenerProcessingContext.textContent])的值为 null 的时候,
* 是否直接放行。如果为 `true`, 则代表匹配值为null的时候视为匹配通过,反之则为匹配失败。默认为 `false`。此参数只有当 [value] 不为空的时候有效。如果 [value] 为空,则不会进行匹配。
* 这并不仅仅局限于[消息事件][love.forte.simbot.event.MessageEvent], 而生效与所有的事件类型。而对于那些本身即不是消息事件的事件来说, `textContent` 默认为null。
*
*/
val ifNullPass: Boolean = false,

/**
* 针对匹配目标所使用的匹配规则。
* 默认情况下使用 [正则完全匹配][MatchType.REGEX_MATCHES].
*/
val matchType: MatchType = MatchType.REGEX_MATCHES,

/**
* 目标过滤内容。
*
Expand All @@ -115,12 +111,12 @@ public annotation class Filter(
@Suppress("DEPRECATION_ERROR")
@Deprecated("Use targets", ReplaceWith("targets"), level = DeprecationLevel.ERROR)
val target: TargetFilter = TargetFilter(),

/*
在 target 还存在的情况下,
当使用了 targets, 则不会使用 target。
*/

/**
* 目标过滤内容。
*
Expand All @@ -129,8 +125,8 @@ public annotation class Filter(
* @see [Targets]
*/
val targets: Targets = Targets(),


/**
* 指定一个对当前 [Filter] 的处理过滤器。当 [by] 指定了任意一个不直接等同于 [AnnotationEventFilterFactory]
* 的类型时,此注解的上述其他参数将不再继续被解析,而是直接交由指定目标进行处理。
Expand All @@ -143,9 +139,9 @@ public annotation class Filter(
*
*/
val by: KClass<out AnnotationEventFilterFactory> = AnnotationEventFilterFactory::class,

) {

/**
* 通用属性过滤规则。
*
Expand Down Expand Up @@ -175,7 +171,7 @@ public annotation class Filter(
* 除了通过此 [components] 作为组件的筛选条件,直接监听一个组件下特有的事件类型能够更好的起到组件过滤的作用。
*/
val components: Array<String> = [],

/**
* 对接收事件的botID匹配。
*
Expand All @@ -185,7 +181,7 @@ public annotation class Filter(
* ```
*/
val bots: Array<String> = [],

/**
* 对消息发送者的ID匹配。
*
Expand All @@ -195,7 +191,7 @@ public annotation class Filter(
* ```
*/
val authors: Array<String> = [],

/**
* 如果这是个[群相关事件][GroupEvent] ,则对群ID匹配。
*
Expand All @@ -206,7 +202,7 @@ public annotation class Filter(
*
*/
val groups: Array<String> = [],

/**
* 如果是个[子频道相关事件][ChannelEvent], 则对频道ID匹配。
*
Expand All @@ -216,12 +212,12 @@ public annotation class Filter(
* ```
*/
val channels: Array<String> = [],

/**
* 如果是个[频道服务器相关事件][GuildEvent], 则对频道服务器ID匹配。
*/
val guilds: Array<String> = [],

/**
* 只有当前消息中存在任意一个 [At.target][love.forte.simbot.message.At.target] == event.bot.id 的 [At][love.forte.simbot.message.At] 消息的时候才会通过匹配。
*
Expand Down Expand Up @@ -273,7 +269,7 @@ public annotation class TargetFilter(
* 除了通过此 [components] 作为组件的筛选条件,直接监听一个组件下特有的事件类型能够更好的起到组件过滤的作用。
*/
val components: Array<String> = [],

/**
* 对接收事件的botID匹配。
*
Expand All @@ -283,7 +279,7 @@ public annotation class TargetFilter(
* ```
*/
val bots: Array<String> = [],

/**
* 对消息发送者的ID匹配。
*
Expand All @@ -293,7 +289,7 @@ public annotation class TargetFilter(
* ```
*/
val authors: Array<String> = [],

/**
* 如果这是个[群相关事件][GroupEvent] ,则对群ID匹配。
*
Expand All @@ -304,7 +300,7 @@ public annotation class TargetFilter(
*
*/
val groups: Array<String> = [],

/**
* 如果是个[子频道相关事件][ChannelEvent], 则对频道ID匹配。
*
Expand All @@ -314,12 +310,12 @@ public annotation class TargetFilter(
* ```
*/
val channels: Array<String> = [],

/**
* 如果是个[频道服务器相关事件][GuildEvent], 则对频道服务器ID匹配。
*/
val guilds: Array<String> = [],

/**
* 只有当前消息中存在任意一个 [At.target][love.forte.simbot.message.At.target] == event.bot.id 的 [At][love.forte.simbot.message.At] 消息的时候才会通过匹配。
*
Expand Down Expand Up @@ -357,9 +353,9 @@ public annotation class Filters(
* 所有子过滤器。
*/
vararg val value: Filter,

/**
* 多个过滤器之间的匹配策略。默认情况下为 [any][MultiFilterMatchType.ANY] 匹配。
*/
val multiMatchType: MultiFilterMatchType = MultiFilterMatchType.ANY,
)
)
@@ -1,17 +1,14 @@
/*
* Copyright (c) 2021-2022 ForteScarlet <ForteScarlet@163.com>
* Copyright (c) 2021-2022 ForteScarlet <ForteScarlet@163.com>
*
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x ) 的一部分。
*
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
*
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x 、simbot3 等) 的一部分。
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
*/

package love.forte.simboot.annotation
Expand Down Expand Up @@ -67,7 +64,6 @@ import kotlin.reflect.KClass
* @see AnnotatedEventListenerInterceptor
*/
@Retention(AnnotationRetention.RUNTIME)
@Repeatable
@JvmRepeatable(Interceptors::class)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
public annotation class Interceptor(
Expand All @@ -77,7 +73,7 @@ public annotation class Interceptor(
* 当使用 [value] 的时候([value] 不为空字符串时),[type]的值将会被忽略。
*/
val value: String = "",

/**
* 通过 **类型** 获取所需拦截器。
* 对于类型的获取,流程如下:
Expand All @@ -89,7 +85,7 @@ public annotation class Interceptor(
*
*/
val type: KClass<out AnnotatedEventListenerInterceptor> = AnnotatedEventListenerInterceptor::class,

/**
* 此拦截器在所有标记的注解拦截器中的优先级。
*/
Expand All @@ -104,4 +100,4 @@ public annotation class Interceptor(
*/
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
public annotation class Interceptors(vararg val value: Interceptor)
public annotation class Interceptors(vararg val value: Interceptor)
@@ -1,17 +1,14 @@
/*
* Copyright (c) 2021-2022 ForteScarlet <ForteScarlet@163.com>
* Copyright (c) 2021-2022 ForteScarlet <ForteScarlet@163.com>
*
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x ) 的一部分。
*
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
*
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x 、simbot3 等) 的一部分。
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
*/

package love.forte.simboot.annotation
Expand All @@ -35,7 +32,6 @@ import kotlin.reflect.KClass
* @see love.forte.simbot.event.Event
*/
@Retention(AnnotationRetention.RUNTIME)
@Repeatable
@JvmRepeatable(Listens::class)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
@MustBeDocumented
Expand All @@ -45,4 +41,4 @@ public annotation class Listen(val value: KClass<out Event>)
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
@MustBeDocumented
public annotation class Listens(vararg val value: Listen)
public annotation class Listens(vararg val value: Listen)
@@ -1,17 +1,14 @@
/*
* Copyright (c) 2022-2022 ForteScarlet <ForteScarlet@163.com>
* Copyright (c) 2022 ForteScarlet <ForteScarlet@163.com>
*
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x ) 的一部分。
*
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
*
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
* 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x 、simbot3 等) 的一部分。
* simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
* 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
*
* 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
* https://www.gnu.org/licenses
* https://www.gnu.org/licenses/gpl-3.0-standalone.html
* https://www.gnu.org/licenses/lgpl-3.0-standalone.html
*/

package love.forte.simboot.annotation
Expand Down Expand Up @@ -43,7 +40,6 @@ public annotation class Preparator(
*
* @see ListenerPreparer
*/
@Repeatable
@JvmRepeatable(Preparers::class)
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
Expand All @@ -59,7 +55,7 @@ public annotation class Preparer(
*
*/
val value: KClass<out ListenerPreparer>,

/**
* 假如提供的 [value] 能够从 bean 容器中获取,
* 可以通过 [name] 指定此 bean 在容器中的唯一标识。
Expand All @@ -68,7 +64,7 @@ public annotation class Preparer(
*
*/
val name: String = "",

/**
* 相对于所有预处理器之间的优先级。
*/
Expand All @@ -81,4 +77,4 @@ public annotation class Preparer(
*/
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
public annotation class Preparers(vararg val value: Preparer)
public annotation class Preparers(vararg val value: Preparer)

0 comments on commit c243ee5

Please sign in to comment.