瀏覽代碼

Support Kotlin 1.6.20-M1 for mirai-console-intellij

Him188 4 年之前
父節點
當前提交
963d5f68b9

+ 5 - 5
buildSrc/build.gradle.kts

@@ -1,10 +1,10 @@
 /*
- * Copyright 2019-2021 Mamoe Technologies and contributors.
+ * Copyright 2019-2022 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.
+ * 此源代码的使用受 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
+ * https://github.com/mamoe/mirai/blob/dev/LICENSE
  */
 
 plugins {
@@ -31,7 +31,7 @@ fun version(name: String): String {
 
     return versionsText.lineSequence()
         .map { it.trim() }
-        .single { it.startsWith("const val $name") }
+        .single { it.startsWith("const val $name ") }
         .substringAfter('"', "")
         .substringBefore('"', "")
         .also {

+ 3 - 0
buildSrc/src/main/kotlin/Versions.kt

@@ -26,6 +26,8 @@ object Versions {
     const val kotlinStdlib = kotlinCompiler
     const val dokka = "1.6.0"
 
+    const val kotlinCompilerForIdeaPlugin = "1.6.20-M1"
+
     const val coroutines = "1.6.0"
     const val atomicFU = "0.17.0"
     const val serialization = "1.2.2"
@@ -127,6 +129,7 @@ val ATTRIBUTE_MIRAI_TARGET_PLATFORM: Attribute<String> = Attribute.of("mirai.tar
 
 
 const val `kotlin-compiler` = "org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}"
+const val `kotlin-compiler_forIdea` = "org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompilerForIdeaPlugin}"
 
 const val `kotlin-stdlib-jdk8` = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlinStdlib}"
 const val `kotlin-reflect` = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlinStdlib}"

+ 6 - 6
mirai-console/tools/compiler-common/build.gradle.kts

@@ -1,10 +1,10 @@
 /*
- * Copyright 2019-2021 Mamoe Technologies and contributors.
+ * Copyright 2019-2022 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.
+ * 此源代码的使用受 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
+ * https://github.com/mamoe/mirai/blob/dev/LICENSE
  */
 
 @file:Suppress("UnusedImport")
@@ -27,8 +27,8 @@ dependencies {
     // api(`kotlinx-coroutines-jdk8`)
     api(project(":mirai-console-compiler-annotations"))
 
-    compileOnly(`kotlin-compiler`)
-    testRuntimeOnly(`kotlin-compiler`)
+    compileOnly(`kotlin-compiler_forIdea`)
+    testRuntimeOnly(`kotlin-compiler_forIdea`)
 }
 
 configurePublishing("mirai-console-compiler-common")

+ 27 - 27
mirai-console/tools/compiler-common/src/diagnostics/MiraiConsoleErrorsRendering.kt

@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2021 Mamoe Technologies and contributors.
+ * Copyright 2019-2022 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.
@@ -40,14 +40,14 @@ object MiraiConsoleErrorsRendering : DefaultErrorMessages.Extension {
         put(
             ILLEGAL_PLUGIN_DESCRIPTION,
             "{0}",
-            Renderers.STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             NOT_CONSTRUCTABLE_TYPE,
             "类型 ''{1}'' 无法通过反射直接构造, 需要提供默认值.",
-            Renderers.EMPTY,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
@@ -59,50 +59,50 @@ object MiraiConsoleErrorsRendering : DefaultErrorMessages.Extension {
         put(
             ILLEGAL_COMMAND_NAME,
             "指令名 ''{0}'' 无效: {1}",
-            Renderers.STRING,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             ILLEGAL_PERMISSION_NAME,
             "权限名 ''{0}'' 无效: {1}",
-            Renderers.STRING,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             ILLEGAL_PERMISSION_ID,
             "权限 Id ''{0}'' 无效: {1}",
-            Renderers.STRING,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             ILLEGAL_PERMISSION_NAMESPACE,
             "权限命名空间 ''{0}'' 无效: {1}",
-            Renderers.STRING,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             ILLEGAL_COMMAND_REGISTER_USE,
             "''{0}'' 无法使用在 ''{1}'' 环境下.",
             Renderers.DECLARATION_NAME,
-            Renderers.STRING
+            Renderers.TO_STRING
         )
 
         put(
             ILLEGAL_PERMISSION_REGISTER_USE,
             "''{0}'' 无法使用在 ''{1}'' 环境下.",
             Renderers.DECLARATION_NAME,
-            Renderers.STRING
+            Renderers.TO_STRING
         )
 
         put(
             ILLEGAL_VERSION_REQUIREMENT,
             "{1}",
-            Renderers.STRING,
-            Renderers.STRING
+            Renderers.TO_STRING,
+            Renderers.TO_STRING
         )
 
         put(
@@ -128,42 +128,42 @@ object MiraiConsoleErrorsRendering : DefaultErrorMessages.Extension {
         put(
             USING_DERIVED_MAP_TYPE,
             "使用 'Map' 的派生类型 {1}.",
-            Renderers.EMPTY,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             USING_DERIVED_MUTABLE_MAP_TYPE,
             "使用 'MutableMap' 的派生类型 {1}.",
-            Renderers.EMPTY,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             USING_DERIVED_LIST_TYPE,
             "使用 'List' 的派生类型 {1}.",
-            Renderers.EMPTY,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             USING_DERIVED_MUTABLE_LIST_TYPE,
             "使用 'MutableList' 的派生类型 {1}.",
-            Renderers.EMPTY,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
         put(
             USING_DERIVED_CONCURRENT_MAP_TYPE,
             "使用 'ConcurrentMap' 的派生类型 {1}.",
-            Renderers.EMPTY,
-            Renderers.STRING,
+            Renderers.TO_STRING,
+            Renderers.TO_STRING,
         )
 
 //        put(
 //            INAPPLICABLE_COMMAND_ANNOTATION,
 //            "''{0}'' 无法在顶层函数使用.",
-//            Renderers.STRING,
+//            Renderers.TO_STRING,
 //        )
     }