2020-09-17 21:39:34 +08:00
|
|
|
/*
|
|
|
|
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
|
|
|
*
|
|
|
|
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
2020-10-28 13:35:15 +08:00
|
|
|
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found through the following link.
|
2020-09-17 21:39:34 +08:00
|
|
|
*
|
|
|
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
package net.mamoe.mirai.console.compiler.common.diagnostics
|
|
|
|
|
2020-11-29 15:05:39 +08:00
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_COMMAND_DECLARATION_RECEIVER
|
2020-10-30 10:28:18 +08:00
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_COMMAND_NAME
|
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_COMMAND_REGISTER_USE
|
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_PERMISSION_ID
|
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_PERMISSION_NAME
|
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_PERMISSION_NAMESPACE
|
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_PERMISSION_REGISTER_USE
|
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_PLUGIN_DESCRIPTION
|
2020-11-26 22:56:51 +08:00
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_VERSION_REQUIREMENT
|
2020-10-30 10:28:18 +08:00
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.NOT_CONSTRUCTABLE_TYPE
|
2020-11-30 14:25:40 +08:00
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.READ_ONLY_VALUE_CANNOT_BE_VAR
|
2020-11-29 16:12:49 +08:00
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.RESTRICTED_CONSOLE_COMMAND_OWNER
|
2020-10-30 10:28:18 +08:00
|
|
|
import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.UNSERIALIZABLE_TYPE
|
2020-09-17 21:39:34 +08:00
|
|
|
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
|
|
|
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap
|
|
|
|
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
|
|
|
|
|
2020-11-25 17:30:52 +08:00
|
|
|
/**
|
|
|
|
* @see MiraiConsoleErrors
|
|
|
|
*/
|
2020-09-17 21:39:34 +08:00
|
|
|
object MiraiConsoleErrorsRendering : DefaultErrorMessages.Extension {
|
|
|
|
private val MAP = DiagnosticFactoryToRendererMap("MiraiConsole").apply {
|
|
|
|
put(
|
2020-09-18 01:49:08 +08:00
|
|
|
ILLEGAL_PLUGIN_DESCRIPTION,
|
|
|
|
"{0}",
|
2020-09-19 00:22:38 +08:00
|
|
|
Renderers.STRING,
|
2020-09-17 21:39:34 +08:00
|
|
|
)
|
2020-09-18 15:36:03 +08:00
|
|
|
|
|
|
|
put(
|
|
|
|
NOT_CONSTRUCTABLE_TYPE,
|
2020-11-10 11:38:24 +08:00
|
|
|
"类型 ''{1}'' 无法通过反射直接构造, 需要提供默认值.",
|
|
|
|
Renderers.EMPTY,
|
2020-09-19 00:22:38 +08:00
|
|
|
Renderers.STRING,
|
2020-09-18 15:36:03 +08:00
|
|
|
)
|
2020-09-18 20:00:47 +08:00
|
|
|
|
|
|
|
put(
|
|
|
|
UNSERIALIZABLE_TYPE,
|
2020-09-19 00:22:38 +08:00
|
|
|
"类型 ''{0}'' 无法被自动序列化, 需要添加序列化器",
|
2020-09-19 01:06:45 +08:00
|
|
|
Renderers.FQ_NAMES_IN_TYPES,
|
2020-09-19 00:22:38 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_COMMAND_NAME,
|
|
|
|
"指令名 ''{0}'' 无效: {1}",
|
|
|
|
Renderers.STRING,
|
|
|
|
Renderers.STRING,
|
|
|
|
)
|
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_PERMISSION_NAME,
|
|
|
|
"权限名 ''{0}'' 无效: {1}",
|
|
|
|
Renderers.STRING,
|
|
|
|
Renderers.STRING,
|
|
|
|
)
|
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_PERMISSION_ID,
|
|
|
|
"权限 Id ''{0}'' 无效: {1}",
|
|
|
|
Renderers.STRING,
|
|
|
|
Renderers.STRING,
|
|
|
|
)
|
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_PERMISSION_NAMESPACE,
|
|
|
|
"权限命名空间 ''{0}'' 无效: {1}",
|
|
|
|
Renderers.STRING,
|
|
|
|
Renderers.STRING,
|
2020-09-18 20:00:47 +08:00
|
|
|
)
|
2020-09-19 13:48:23 +08:00
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_COMMAND_REGISTER_USE,
|
|
|
|
"''{0}'' 无法使用在 ''{1}'' 环境下.",
|
|
|
|
Renderers.DECLARATION_NAME,
|
|
|
|
Renderers.STRING
|
|
|
|
)
|
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_PERMISSION_REGISTER_USE,
|
|
|
|
"''{0}'' 无法使用在 ''{1}'' 环境下.",
|
|
|
|
Renderers.DECLARATION_NAME,
|
|
|
|
Renderers.STRING
|
|
|
|
)
|
2020-11-26 22:56:51 +08:00
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_VERSION_REQUIREMENT,
|
|
|
|
"{1}",
|
|
|
|
Renderers.STRING,
|
|
|
|
Renderers.STRING
|
|
|
|
)
|
2020-11-29 15:05:39 +08:00
|
|
|
|
|
|
|
put(
|
|
|
|
ILLEGAL_COMMAND_DECLARATION_RECEIVER,
|
|
|
|
"指令函数的接收者参数必须为 CommandSender 及其子类或无接收者.",
|
|
|
|
)
|
|
|
|
|
2020-11-29 16:12:49 +08:00
|
|
|
put(
|
|
|
|
RESTRICTED_CONSOLE_COMMAND_OWNER,
|
|
|
|
"插件不允许使用 ConsoleCommandOwner 构造指令, 请使用插件主类作为 CommandOwner",
|
|
|
|
)
|
|
|
|
|
2020-11-30 14:25:40 +08:00
|
|
|
put(
|
|
|
|
READ_ONLY_VALUE_CANNOT_BE_VAR,
|
|
|
|
"在 ReadOnlyPluginData 中不可定义 'var' by value",
|
|
|
|
)
|
|
|
|
|
2020-11-29 15:05:39 +08:00
|
|
|
// put(
|
|
|
|
// INAPPLICABLE_COMMAND_ANNOTATION,
|
|
|
|
// "''{0}'' 无法在顶层函数使用.",
|
|
|
|
// Renderers.STRING,
|
|
|
|
// )
|
2020-09-17 21:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun getMap() = MAP
|
|
|
|
}
|