Correct package (not affecting API)

This commit is contained in:
Him188 2020-11-30 12:09:10 +08:00
parent 6f32ba325b
commit 64e0d545f4
3 changed files with 1 additions and 122 deletions

View File

@ -1,93 +0,0 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* 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.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:Suppress("unused")
package net.mamoe.mirai.console.compiler.common
import net.mamoe.mirai.console.command.Command
import net.mamoe.mirai.console.data.PluginData
import net.mamoe.mirai.console.data.value
import net.mamoe.mirai.console.permission.PermissionId
import net.mamoe.mirai.console.plugin.description.PluginDescription
import net.mamoe.mirai.console.util.SemVersion
import kotlin.annotation.AnnotationTarget.*
/**
* 标记一个参数的语境类型, 用于帮助编译器和 IntelliJ 插件进行语境推断.
*/
@Target(VALUE_PARAMETER, PROPERTY, FIELD, FUNCTION, TYPE, TYPE_PARAMETER)
@Retention(AnnotationRetention.BINARY)
public annotation class ResolveContext(
vararg val kinds: Kind,
) {
/**
* 元素数量可能在任意时间被改动
*/
public enum class Kind {
///////////////////////////////////////////////////////////////////////////
// ConstantKind
///////////////////////////////////////////////////////////////////////////
/*
* WARNING: IF YOU CHANGE NAMES HERE,
* YOU SHOULD ALSO CHANGE THEIR COUNTERPARTS AT net.mamoe.mirai.console.compiler.common.resolve.ResolveContextKind
*/
/**
* @see PluginDescription.id
*/
PLUGIN_ID, // ILLEGAL_PLUGIN_DESCRIPTION
/**
* @see PluginDescription.name
*/
PLUGIN_NAME, // ILLEGAL_PLUGIN_DESCRIPTION
/**
* @see PluginDescription.version
* @see SemVersion.Companion.invoke
*/
SEMANTIC_VERSION, // ILLEGAL_PLUGIN_DESCRIPTION
/**
* @see SemVersion.Companion.parseRangeRequirement
*/
VERSION_REQUIREMENT, // ILLEGAL_VERSION_REQUIREMENT
/**
* @see Command.allNames
*/
COMMAND_NAME, // ILLEGAL_COMMAND_NAME
/**
* @see PermissionId.name
*/
PERMISSION_NAMESPACE, // ILLEGAL_PERMISSION_NAMESPACE
/**
* @see PermissionId.name
*/
PERMISSION_NAME, // ILLEGAL_PERMISSION_NAME
/**
* @see PermissionId.parseFromString
*/
PERMISSION_ID, // ILLEGAL_PERMISSION_ID
/**
* 标注一个泛型, 要求这个泛型必须拥有一个公开无参 (或所有参数都可选) 构造器.
*
* @see PluginData.value
*/
RESTRICTED_NO_ARG_CONSTRUCTOR, // NOT_CONSTRUCTABLE_TYPE
RESTRICTED_CONSOLE_COMMAND_OWNER,
}
}

View File

@ -1,28 +0,0 @@
/*
* Copyright 2019-2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* 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.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package net.mamoe.mirai.console.compiler.common
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
import kotlin.annotation.AnnotationTarget.FUNCTION
/**
* 标记一个函数, 在其函数体内限制特定一些函数的使用.
*/
@ConsoleExperimentalApi
@Target(FUNCTION)
@Retention(AnnotationRetention.BINARY)
public annotation class RestrictedScope(
vararg val kinds: Kind,
) {
public enum class Kind {
PERMISSION_REGISTER, // ILLEGAL_PERMISSION_REGISTER_USE
COMMAND_REGISTER, // ILLEGAL_COMMAND_REGISTER_USE
}
}

View File

@ -8,7 +8,7 @@ IntelliJ 平台的 Mirai Console 开发插件
#### ILLEGAL_PLUGIN_DESCRIPTION
- 使用 [ResolveContext](../../backend/mirai-console/src/common/ResolveContext.kt)
- 使用 [ResolveContext](../../backend/mirai-console/src/compiler/common/ResolveContext.kt)
- 检测 Plugin Id, Plugin Name, Plugin Version 的合法性. 并在非法时提示正确的语法.
- 支持编译期常量