From d0b71b200f3613264d29981695b89054dff6b308 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Wed, 21 Oct 2020 00:02:55 +0800 Subject: [PATCH 01/14] block whitespace in permission id - blocked all whitespace - Update IntelliJ IDEA plugin message - Bump IntelliJ IDEA testing project version - Add tests for permission id --- .../net/mamoe/mirai/console/permission/PermissionId.kt | 4 ++-- .../mirai/console/permission/PermissionsBasicsTest.kt | 10 ++++++++++ .../run/projects/test-project/build.gradle.kts | 8 ++++---- .../main/kotlin/org/example/myplugin/MyPluginMain.kt | 2 ++ .../diagnostics/ContextualParametersChecker.kt | 4 ++-- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt index 9a92e8be2..b34171aba 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionId.kt @@ -31,10 +31,10 @@ public data class PermissionId( @ResolveContext(PERMISSION_NAME) public val name: String, ) { init { - require(!namespace.contains(' ')) { + require(namespace.none { it.isWhitespace() }) { "' ' is not allowed in namespace" } - require(!name.contains(' ')) { + require(name.none { it.isWhitespace() }) { "' ' is not allowed in id" } diff --git a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/permission/PermissionsBasicsTest.kt b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/permission/PermissionsBasicsTest.kt index f60845990..3a8e203bb 100644 --- a/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/permission/PermissionsBasicsTest.kt +++ b/backend/mirai-console/src/test/kotlin/net/mamoe/mirai/console/permission/PermissionsBasicsTest.kt @@ -1,8 +1,18 @@ package net.mamoe.mirai.console.permission import org.junit.jupiter.api.Test +import kotlin.test.assertFails internal class PermissionsBasicsTest { + @Test + fun testInvalidPermissionId() { + assertFails { PermissionId("space namespace", "name") } + assertFails { PermissionId("namespace", "space name") } + // assertFails { PermissionId("", "name") } + // assertFails { PermissionId("namespace", "") } + assertFails { PermissionId("namespace:name", "name") } + assertFails { PermissionId("namespace", "namespace:name") } + } @Test fun parentsWithSelfSequence() { diff --git a/tools/intellij-plugin/run/projects/test-project/build.gradle.kts b/tools/intellij-plugin/run/projects/test-project/build.gradle.kts index e1c0ff8b7..7125213bc 100644 --- a/tools/intellij-plugin/run/projects/test-project/build.gradle.kts +++ b/tools/intellij-plugin/run/projects/test-project/build.gradle.kts @@ -1,7 +1,7 @@ plugins { - kotlin("jvm") version "1.4.0" - kotlin("plugin.serialization") version "1.4.0" - kotlin("kapt") version "1.4.0" + kotlin("jvm") version "1.4.10" + kotlin("plugin.serialization") version "1.4.10" + kotlin("kapt") version "1.4.10" id("com.github.johnrengelman.shadow") version "5.2.0" } @@ -33,7 +33,7 @@ dependencies { testImplementation("net.mamoe:mirai-console:$console") testImplementation("net.mamoe:mirai-core:$core") - testImplementation("net.mamoe:mirai-console-pure:$console") + testImplementation("net.mamoe:mirai-console-terminal:$console") testImplementation(kotlin("stdlib-jdk8")) } diff --git a/tools/intellij-plugin/run/projects/test-project/src/main/kotlin/org/example/myplugin/MyPluginMain.kt b/tools/intellij-plugin/run/projects/test-project/src/main/kotlin/org/example/myplugin/MyPluginMain.kt index b010e4c9f..7c90205d7 100644 --- a/tools/intellij-plugin/run/projects/test-project/src/main/kotlin/org/example/myplugin/MyPluginMain.kt +++ b/tools/intellij-plugin/run/projects/test-project/src/main/kotlin/org/example/myplugin/MyPluginMain.kt @@ -21,6 +21,8 @@ object MyPluginMain : KotlinPlugin( override fun onEnable() { super.onEnable() PermissionService.INSTANCE.register(permissionId("dvs"), "ok") + PermissionService.INSTANCE.register(permissionId("perm with space"), "error") + PermissionId("Namespace with space", "Name with space") } fun test() { diff --git a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt index 790ba9596..6e074156f 100644 --- a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt +++ b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt @@ -85,7 +85,7 @@ class ContextualParametersChecker : DeclarationChecker { fun checkPermissionNamespace(inspectionTarget: PsiElement, value: String): Diagnostic? { return when { value.isBlank() -> ILLEGAL_PERMISSION_NAMESPACE.on(inspectionTarget, value, "权限命名空间不能为空") - value.any { it.isWhitespace() } -> ILLEGAL_PERMISSION_NAMESPACE.on(inspectionTarget, value, "暂时不允许权限命名空间中存在空格") + value.any { it.isWhitespace() } -> ILLEGAL_PERMISSION_NAMESPACE.on(inspectionTarget, value, "不允许权限命名空间中存在空格") value.contains(':') -> ILLEGAL_PERMISSION_NAMESPACE.on(inspectionTarget, value, "权限命名空间不允许包含 ':'") else -> null } @@ -94,7 +94,7 @@ class ContextualParametersChecker : DeclarationChecker { fun checkPermissionName(inspectionTarget: PsiElement, value: String): Diagnostic? { return when { value.isBlank() -> ILLEGAL_PERMISSION_NAME.on(inspectionTarget, value, "权限名称不能为空") - value.any { it.isWhitespace() } -> ILLEGAL_PERMISSION_NAME.on(inspectionTarget, value, "暂时不允许权限名称中存在空格") + value.any { it.isWhitespace() } -> ILLEGAL_PERMISSION_NAME.on(inspectionTarget, value, "不允许权限名称中存在空格") value.contains(':') -> ILLEGAL_PERMISSION_NAME.on(inspectionTarget, value, "权限名称不允许包含 ':'") else -> null } From cdfa5df18962dbab419fd1ae0a8d7175f9fb2536 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Thu, 22 Oct 2020 00:33:04 +0800 Subject: [PATCH 02/14] Use plugin id not name --- .../net/mamoe/mirai/console/permission/PermissionService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt index 32e3d57fd..dc284650e 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/permission/PermissionService.kt @@ -17,6 +17,7 @@ import net.mamoe.mirai.console.extensions.PermissionServiceProvider import net.mamoe.mirai.console.internal.permission.checkType import net.mamoe.mirai.console.permission.Permission.Companion.parentsWithSelf import net.mamoe.mirai.console.plugin.Plugin +import net.mamoe.mirai.console.plugin.description import net.mamoe.mirai.console.plugin.name import kotlin.reflect.KClass @@ -154,7 +155,7 @@ public interface PermissionService

{ @ResolveContext(COMMAND_NAME) permissionName: String, reason: PluginPermissionIdRequestType ) = PermissionId( - plugin.name.toLowerCase().replace(' ', '.'), + plugin.description.id.toLowerCase(), permissionName.toLowerCase() ) From 33141258f22338b171f738fe7c5feb1a791c09fb Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 12:40:37 +0800 Subject: [PATCH 03/14] Use Lazy.PUBLICATION for SemVersion.toString --- .../src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt index a80c467a2..c96e2950f 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt @@ -26,6 +26,7 @@ import net.mamoe.mirai.console.internal.data.map import net.mamoe.mirai.console.internal.util.semver.SemVersionInternal import net.mamoe.mirai.console.util.SemVersion.Companion.equals import net.mamoe.mirai.console.util.SemVersion.Requirement +import kotlin.LazyThreadSafetyMode.PUBLICATION /** * [语义化版本](https://semver.org/lang/zh-CN/) 支持 @@ -163,7 +164,7 @@ internal constructor( } @Transient - private val toString: String by lazy(LazyThreadSafetyMode.NONE) { + private val toString: String by lazy(PUBLICATION) { buildString { append(major) append('.').append(minor) From 643ac52bc7cd5a68e51bd2b138abc7dea2c52484 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 12:40:50 +0800 Subject: [PATCH 04/14] Update docs --- .../mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt index 954d19919..71b1f97a9 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt @@ -176,6 +176,8 @@ public class JvmPluginDescriptionBuilder( /** * 无版本要求 * + * @param isOptional [PluginDependency.isOptional] + * * @see PluginDependency */ @ILoveKuriyamaMiraiForever @@ -187,8 +189,8 @@ public class JvmPluginDescriptionBuilder( } - @Suppress("DEPRECATION_ERROR") public fun build(): JvmPluginDescription = + @Suppress("DEPRECATION_ERROR") SimpleJvmPluginDescription(name, version, id, author, info, dependencies) /** From e303eae15ac44d64e9976843a4c759c0084cafb8 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 12:49:00 +0800 Subject: [PATCH 05/14] Add String variant of dependsOn.versionRequirement; Add ResolveContext.VERSION_REQUIREMENT --- .../console/compiler/common/ResolveContext.kt | 2 ++ .../plugin/jvm/JvmPluginDescription.kt | 27 ++++++++++--------- .../mamoe/mirai/console/util/SemVersion.kt | 9 ++++++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/compiler/common/ResolveContext.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/compiler/common/ResolveContext.kt index 9dff987e2..a10aa00d8 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/compiler/common/ResolveContext.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/compiler/common/ResolveContext.kt @@ -40,6 +40,8 @@ public annotation class ResolveContext( PLUGIN_NAME, // ILLEGAL_PLUGIN_DESCRIPTION PLUGIN_VERSION, // ILLEGAL_PLUGIN_DESCRIPTION + VERSION_REQUIREMENT, // ILLEGAL_VERSION_REQUIREMENT // TODO + COMMAND_NAME, // ILLEGAL_COMMAND_NAME PERMISSION_NAMESPACE, // ILLEGAL_COMMAND_NAMESPACE diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt index 71b1f97a9..8a08a4cb7 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt @@ -148,18 +148,6 @@ public class JvmPluginDescriptionBuilder( } } - /** - * @see PluginDependency - */ - @ILoveKuriyamaMiraiForever - public fun dependsOn( - @ResolveContext(PLUGIN_ID) pluginId: String, - isOptional: Boolean = false, - versionRequirement: SemVersion.Requirement, - ): JvmPluginDescriptionBuilder = apply { - this.dependencies.add(PluginDependency(pluginId, versionRequirement, isOptional)) - } - /** * isOptional = false * @@ -169,8 +157,21 @@ public class JvmPluginDescriptionBuilder( public fun dependsOn( @ResolveContext(PLUGIN_ID) pluginId: String, versionRequirement: SemVersion.Requirement, + isOptional: Boolean = false, ): JvmPluginDescriptionBuilder = apply { - this.dependencies.add(PluginDependency(pluginId, versionRequirement, false)) + this.dependencies.add(PluginDependency(pluginId, versionRequirement, isOptional)) + } + + /** + * @see PluginDependency + */ + @ILoveKuriyamaMiraiForever + public fun dependsOn( + @ResolveContext(PLUGIN_ID) pluginId: String, + @ResolveContext(VERSION_REQUIREMENT) versionRequirement: String, + isOptional: Boolean = false, + ): JvmPluginDescriptionBuilder = apply { + this.dependencies.add(PluginDependency(pluginId, SemVersion.parseRangeRequirement(versionRequirement), isOptional)) } /** diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt index c96e2950f..89519e813 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersion.kt @@ -22,6 +22,7 @@ import kotlinx.serialization.Transient import kotlinx.serialization.builtins.serializer import net.mamoe.mirai.console.compiler.common.ResolveContext import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.PLUGIN_VERSION +import net.mamoe.mirai.console.compiler.common.ResolveContext.Kind.VERSION_REQUIREMENT import net.mamoe.mirai.console.internal.data.map import net.mamoe.mirai.console.internal.util.semver.SemVersionInternal import net.mamoe.mirai.console.util.SemVersion.Companion.equals @@ -139,7 +140,7 @@ internal constructor( */ @Throws(IllegalArgumentException::class) @JvmStatic - public fun parseRangeRequirement(requirement: String): Requirement = + public fun parseRangeRequirement(@ResolveContext(VERSION_REQUIREMENT) requirement: String): Requirement = SemVersionInternal.parseRangeRequirement(requirement) /** @see [Requirement.test] */ @@ -152,6 +153,12 @@ internal constructor( @JvmStatic public fun SemVersion.satisfies(requirement: Requirement): Boolean = requirement.test(this) + /** + * 当满足 [requirement] 时返回 true, 否则返回 false + */ + @JvmStatic + public fun SemVersion.satisfies(@ResolveContext(VERSION_REQUIREMENT) requirement: String): Boolean = parseRangeRequirement(requirement).test(this) + /** for Kotlin only */ @JvmStatic @JvmSynthetic From 075a2bd519b24bac86337bc57066b472dc9bc551 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 12:54:36 +0800 Subject: [PATCH 06/14] Add ResolveContext to JvmPluginDescriptionBuilder.id --- .../net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt index 8a08a4cb7..2585888ff 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt @@ -97,7 +97,7 @@ public interface JvmPluginDescription : PluginDescription { * @see [JvmPluginDescription.invoke] */ public class JvmPluginDescriptionBuilder( - private var id: String, + @ResolveContext(PLUGIN_ID) private var id: String, private var version: SemVersion, ) { public constructor( From 0ae03d141ecac3e3940135f0e3988233ffd1e66d Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 12:55:44 +0800 Subject: [PATCH 07/14] Remove ResolveContext misuse --- .../net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt index 2585888ff..d4944870e 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt @@ -119,7 +119,7 @@ public class JvmPluginDescriptionBuilder( apply { this.version = SemVersion(value) } @ILoveKuriyamaMiraiForever - public fun version(@ResolveContext(PLUGIN_VERSION) value: SemVersion): JvmPluginDescriptionBuilder = + public fun version(value: SemVersion): JvmPluginDescriptionBuilder = apply { this.version = value } @ILoveKuriyamaMiraiForever From 3ce1e4f0290874c7b72411380820f3c536061cde Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 12:57:25 +0800 Subject: [PATCH 08/14] Fix docs --- .../mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt index d4944870e..d49fcd846 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt @@ -87,11 +87,11 @@ public interface JvmPluginDescription : PluginDescription { * ``` * * #### Java Example - * ``` + * ```java * JvmPluginDescription desc = new JvmPluginDescriptionBuilder("org.example.example-plugin", "1.0.0") * .info("This is an example plugin") * .dependsOn("org.example.another-plugin") - * .build() + * .build(); * ``` * * @see [JvmPluginDescription.invoke] From fc5fc18913fbe5bec2d921a255ffffabfed68e07 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 12:57:39 +0800 Subject: [PATCH 09/14] Make JvmPluginDescription.Companion.invoke inline --- .../mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt index d49fcd846..72c376b94 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt @@ -35,7 +35,7 @@ public interface JvmPluginDescription : PluginDescription { */ @JvmName("create") @JvmSynthetic - public operator fun invoke( + public inline operator fun invoke( /** * @see [PluginDescription.id] */ @@ -57,7 +57,7 @@ public interface JvmPluginDescription : PluginDescription { */ @JvmName("create") @JvmSynthetic - public operator fun invoke( + public inline operator fun invoke( /** * @see [PluginDescription.id] */ From 9adc4cde5563840a4c3f1710c28a6d06abd8790d Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 13:00:08 +0800 Subject: [PATCH 10/14] Do checkPluginDescription in SimpleJvmPluginDescription.init --- .../mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt index 72c376b94..edf5d99af 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/jvm/JvmPluginDescription.kt @@ -65,7 +65,7 @@ public interface JvmPluginDescription : PluginDescription { /** * @see [PluginDescription.version] */ - @ResolveContext(PLUGIN_VERSION) version: SemVersion, + version: SemVersion, /** * @see [PluginDescription.name] */ @@ -230,6 +230,6 @@ internal data class SimpleJvmPluginDescription ) : this(name, SemVersion(version), id, author, info, dependencies) init { - require(!name.contains(':')) { "':' is forbidden in plugin name" } + PluginDescription.checkPluginDescription(this) } } \ No newline at end of file From ca95add438a38bc30b13b4067417d9d62526da14 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 13:06:55 +0800 Subject: [PATCH 11/14] Add checkVersionRequirement --- .../mirai/console/compiler/common/resolve/resolveTypes.kt | 2 ++ .../intellij/diagnostics/ContextualParametersChecker.kt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/tools/compiler-common/src/main/kotlin/net/mamoe/mirai/console/compiler/common/resolve/resolveTypes.kt b/tools/compiler-common/src/main/kotlin/net/mamoe/mirai/console/compiler/common/resolve/resolveTypes.kt index 463321b14..59f356cc9 100644 --- a/tools/compiler-common/src/main/kotlin/net/mamoe/mirai/console/compiler/common/resolve/resolveTypes.kt +++ b/tools/compiler-common/src/main/kotlin/net/mamoe/mirai/console/compiler/common/resolve/resolveTypes.kt @@ -57,6 +57,8 @@ enum class ResolveContextKind { PLUGIN_NAME, PLUGIN_VERSION, + VERSION_REQUIREMENT, + COMMAND_NAME, PERMISSION_NAMESPACE, diff --git a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt index 6e074156f..ecf455dc4 100644 --- a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt +++ b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt @@ -108,6 +108,12 @@ class ContextualParametersChecker : DeclarationChecker { else -> null } } + + @Suppress("UNUSED_PARAMETER") + fun checkVersionRequirement(inspectionTarget: PsiElement, value: String): Diagnostic? { + // TODO: 2020/10/23 checkVersionRequirement + return null + } } private val checkersMap: EnumMap Diagnostic?> = @@ -119,6 +125,7 @@ class ContextualParametersChecker : DeclarationChecker { put(ResolveContextKind.PERMISSION_NAME, ::checkPermissionName) put(ResolveContextKind.PERMISSION_NAMESPACE, ::checkPermissionNamespace) put(ResolveContextKind.PERMISSION_ID, ::checkPermissionId) + put(ResolveContextKind.VERSION_REQUIREMENT, ::checkVersionRequirement) } override fun check( From 3ac20e3177ad08f59969b13c28a1992f4e411b1c Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 13:11:30 +0800 Subject: [PATCH 12/14] Change AddSerializerFix.familyName to "Mirai Console" --- .../mirai/console/intellij/diagnostics/fix/AddSerializerFix.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/fix/AddSerializerFix.kt b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/fix/AddSerializerFix.kt index c276b3c8c..e2cb8625c 100644 --- a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/fix/AddSerializerFix.kt +++ b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/fix/AddSerializerFix.kt @@ -25,7 +25,7 @@ class AddSerializerFix( element: KtClassOrObject, ) : KotlinCrossLanguageQuickFixAction(element), KotlinUniversalQuickFix { - override fun getFamilyName(): String = "添加注解" + override fun getFamilyName(): String = "Mirai Console" override fun getText(): String = "添加 @Serializable" override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { From 27aff26bfdb42c555f5f13580863807606539ccc Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 23 Oct 2020 13:15:09 +0800 Subject: [PATCH 13/14] 1.0-RC-dev-31 --- buildSrc/src/main/kotlin/Versions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index d5f4b7ac6..37a6ea152 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -9,7 +9,7 @@ object Versions { const val core = "1.3.0" - const val console = "1.0-RC-dev-30" + const val console = "1.0-RC-dev-31" const val consoleGraphical = "0.0.7" const val consoleTerminal = console From 4564531f8b0300e8227bfc99dff80e6c16e262e8 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Fri, 23 Oct 2020 18:03:41 +0800 Subject: [PATCH 14/14] Fix atomic value updating --- .../mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt index 9284baaa1..fbe937d23 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/plugin/JvmPluginInternal.kt @@ -182,7 +182,7 @@ internal inline fun AtomicLong.updateWhen(condition: (Long) -> Boolean, update: while (true) { val current = value if (condition(current)) { - if (compareAndSet(0, update(current))) { + if (compareAndSet(current, update(current))) { return true } else continue }