mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-26 16:10:11 +08:00
Extract ResolveContext and RestrictedScope to separate modules
This commit is contained in:
parent
c697668f53
commit
4769a0995d
@ -39,6 +39,8 @@ dependencies {
|
|||||||
compileAndTestRuntime(`kotlinx-serialization-json`)
|
compileAndTestRuntime(`kotlinx-serialization-json`)
|
||||||
compileAndTestRuntime(`kotlin-reflect`)
|
compileAndTestRuntime(`kotlin-reflect`)
|
||||||
|
|
||||||
|
implementation(project(":mirai-console-compiler-annotations"))
|
||||||
|
|
||||||
smartImplementation(yamlkt)
|
smartImplementation(yamlkt)
|
||||||
smartImplementation(`jetbrains-annotations`)
|
smartImplementation(`jetbrains-annotations`)
|
||||||
smartImplementation(`caller-finder`)
|
smartImplementation(`caller-finder`)
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2021 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.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
@ -17,6 +26,7 @@ fun includeProject(projectPath: String, path: String? = null) {
|
|||||||
if (path != null) project(projectPath).projectDir = file(path)
|
if (path != null) project(projectPath).projectDir = file(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
includeProject(":mirai-console-compiler-annotations", "tools/compiler-annotations")
|
||||||
includeProject(":mirai-console", "backend/mirai-console")
|
includeProject(":mirai-console", "backend/mirai-console")
|
||||||
includeProject(":mirai-console.codegen", "backend/codegen")
|
includeProject(":mirai-console.codegen", "backend/codegen")
|
||||||
includeProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
|
includeProject(":mirai-console-terminal", "frontend/mirai-console-terminal")
|
||||||
|
5
tools/compiler-annotations/README.md
Normal file
5
tools/compiler-annotations/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# mirai-console-compiler-common
|
||||||
|
|
||||||
|
Mirai Console 编译器注解模块。
|
||||||
|
|
||||||
|
提供 `ResolveContext` 和 `RestrictedScope`,帮助 [IntelliJ 插件](../intellij-plugin) 进行语境推断。
|
26
tools/compiler-annotations/build.gradle.kts
Normal file
26
tools/compiler-annotations/build.gradle.kts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019-2021 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.
|
||||||
|
*
|
||||||
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("UnusedImport")
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
id("java")
|
||||||
|
`maven-publish`
|
||||||
|
id("com.jfrog.bintray")
|
||||||
|
}
|
||||||
|
|
||||||
|
version = Versions.console
|
||||||
|
description = "Mirai Console compiler annotations"
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
explicitApi()
|
||||||
|
}
|
||||||
|
|
||||||
|
configurePublishing("mirai-console-compiler-annotations")
|
@ -1,22 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* 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/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("unused")
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package net.mamoe.mirai.console.compiler.common
|
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.*
|
import kotlin.annotation.AnnotationTarget.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,53 +35,57 @@ public annotation class ResolveContext(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PluginDescription.id
|
* PluginDescription.id
|
||||||
*/
|
*/
|
||||||
PLUGIN_ID, // ILLEGAL_PLUGIN_DESCRIPTION
|
PLUGIN_ID, // ILLEGAL_PLUGIN_DESCRIPTION
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PluginDescription.name
|
* PluginDescription.name
|
||||||
*/
|
*/
|
||||||
PLUGIN_NAME, // ILLEGAL_PLUGIN_DESCRIPTION
|
PLUGIN_NAME, // ILLEGAL_PLUGIN_DESCRIPTION
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PluginDescription.version
|
* PluginDescription.version
|
||||||
* @see SemVersion.Companion.invoke
|
* SemVersion.Companion.invoke
|
||||||
*/
|
*/
|
||||||
SEMANTIC_VERSION, // ILLEGAL_PLUGIN_DESCRIPTION
|
SEMANTIC_VERSION, // ILLEGAL_PLUGIN_DESCRIPTION
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see SemVersion.Companion.parseRangeRequirement
|
* SemVersion.Companion.parseRangeRequirement
|
||||||
*/
|
*/
|
||||||
VERSION_REQUIREMENT, // ILLEGAL_VERSION_REQUIREMENT
|
VERSION_REQUIREMENT, // ILLEGAL_VERSION_REQUIREMENT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Command.allNames
|
* Command.allNames
|
||||||
*/
|
*/
|
||||||
COMMAND_NAME, // ILLEGAL_COMMAND_NAME
|
COMMAND_NAME, // ILLEGAL_COMMAND_NAME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PermissionId.name
|
* PermissionId.name
|
||||||
*/
|
*/
|
||||||
PERMISSION_NAMESPACE, // ILLEGAL_PERMISSION_NAMESPACE
|
PERMISSION_NAMESPACE, // ILLEGAL_PERMISSION_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PermissionId.name
|
* PermissionId.name
|
||||||
*/
|
*/
|
||||||
PERMISSION_NAME, // ILLEGAL_PERMISSION_NAME
|
PERMISSION_NAME, // ILLEGAL_PERMISSION_NAME
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PermissionId.parseFromString
|
* PermissionId.parseFromString
|
||||||
*/
|
*/
|
||||||
PERMISSION_ID, // ILLEGAL_PERMISSION_ID
|
PERMISSION_ID, // ILLEGAL_PERMISSION_ID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标注一个泛型, 要求这个泛型必须拥有一个公开无参 (或所有参数都可选) 构造器.
|
* 标注一个泛型, 要求这个泛型必须拥有一个公开无参 (或所有参数都可选) 构造器.
|
||||||
*
|
*
|
||||||
* @see PluginData.value
|
* PluginData.value
|
||||||
*/
|
*/
|
||||||
RESTRICTED_NO_ARG_CONSTRUCTOR, // NOT_CONSTRUCTABLE_TYPE
|
RESTRICTED_NO_ARG_CONSTRUCTOR, // NOT_CONSTRUCTABLE_TYPE
|
||||||
|
|
||||||
RESTRICTED_CONSOLE_COMMAND_OWNER,
|
RESTRICTED_CONSOLE_COMMAND_OWNER, ;
|
||||||
|
|
||||||
|
public companion object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public companion object
|
||||||
}
|
}
|
@ -1,21 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* 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/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.mamoe.mirai.console.compiler.common
|
package net.mamoe.mirai.console.compiler.common
|
||||||
|
|
||||||
import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
|
||||||
import kotlin.annotation.AnnotationTarget.FUNCTION
|
import kotlin.annotation.AnnotationTarget.FUNCTION
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标记一个函数, 在其函数体内限制特定一些函数的使用.
|
* 标记一个函数, 在其函数体内限制特定一些函数的使用.
|
||||||
|
*
|
||||||
|
* @suppress 这是实验性 API, 可能会在未来有不兼容变更
|
||||||
*/
|
*/
|
||||||
@ConsoleExperimentalApi
|
|
||||||
@Target(FUNCTION)
|
@Target(FUNCTION)
|
||||||
@Retention(AnnotationRetention.BINARY)
|
@Retention(AnnotationRetention.BINARY)
|
||||||
public annotation class RestrictedScope(
|
public annotation class RestrictedScope(
|
@ -21,14 +21,15 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
version = Versions.console
|
version = Versions.console
|
||||||
description = "Mirai Console compiler common"
|
description = "Mirai Console compiler resolve"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(`jetbrains-annotations`)
|
api(`jetbrains-annotations`)
|
||||||
// api(`kotlinx-coroutines-jdk8`)
|
// api(`kotlinx-coroutines-jdk8`)
|
||||||
|
api(project(":mirai-console-compiler-annotations"))
|
||||||
|
|
||||||
compileOnly(`kotlin-compiler`)
|
compileOnly(`kotlin-compiler`)
|
||||||
testRuntimeOnly(`kotlin-compiler`)
|
testRuntimeOnly(`kotlin-compiler`)
|
||||||
}
|
}
|
||||||
|
|
||||||
configurePublishing("mirai-console-compiler-common")
|
configurePublishing("mirai-console-compiler-resolve")
|
@ -1,16 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
* Copyright 2019-2021 Mamoe Technologies and contributors.
|
||||||
*
|
*
|
||||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* 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/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("unused")
|
@file:Suppress("unused")
|
||||||
|
|
||||||
package net.mamoe.mirai.console.compiler.common.resolve
|
package net.mamoe.mirai.console.compiler.common.resolve
|
||||||
|
|
||||||
|
import net.mamoe.mirai.console.compiler.common.ResolveContext
|
||||||
import net.mamoe.mirai.console.compiler.common.castOrNull
|
import net.mamoe.mirai.console.compiler.common.castOrNull
|
||||||
import net.mamoe.mirai.console.compiler.common.firstValue
|
import net.mamoe.mirai.console.compiler.common.firstValue
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||||
@ -60,27 +61,9 @@ val RESOLVE_CONTEXT_FQ_NAME = FqName("net.mamoe.mirai.console.compiler.common.Re
|
|||||||
/**
|
/**
|
||||||
* net.mamoe.mirai.console.compiler.common.ResolveContext.Kind
|
* net.mamoe.mirai.console.compiler.common.ResolveContext.Kind
|
||||||
*/
|
*/
|
||||||
enum class ResolveContextKind {
|
typealias ResolveContextKind = ResolveContext.Kind
|
||||||
PLUGIN_ID,
|
|
||||||
PLUGIN_NAME,
|
|
||||||
SEMANTIC_VERSION,
|
|
||||||
|
|
||||||
VERSION_REQUIREMENT,
|
fun ResolveContext.Kind.Companion.valueOfOrNull(string: String) = ResolveContext.Kind.values().find { it.name == string }
|
||||||
|
|
||||||
COMMAND_NAME,
|
|
||||||
|
|
||||||
PERMISSION_NAMESPACE,
|
|
||||||
PERMISSION_NAME,
|
|
||||||
PERMISSION_ID,
|
|
||||||
|
|
||||||
RESTRICTED_NO_ARG_CONSTRUCTOR,
|
|
||||||
RESTRICTED_CONSOLE_COMMAND_OWNER,
|
|
||||||
;
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun valueOfOrNull(string: String) = values().find { it.name == string }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val Annotated.resolveContextKinds: List<ResolveContextKind>?
|
val Annotated.resolveContextKinds: List<ResolveContextKind>?
|
||||||
get() {
|
get() {
|
||||||
|
@ -10,6 +10,6 @@
|
|||||||
package net.mamoe.mirai.console.gradle
|
package net.mamoe.mirai.console.gradle
|
||||||
|
|
||||||
internal object VersionConstants {
|
internal object VersionConstants {
|
||||||
const val CONSOLE_VERSION = "2.2.0-dev-5" // value is written here automatically during build
|
const val CONSOLE_VERSION = "2.2.0-dev-6" // value is written here automatically during build
|
||||||
const val CORE_VERSION = "2.2.0-dev-5" // value is written here automatically during build
|
const val CORE_VERSION = "2.2.0-dev-6" // value is written here automatically during build
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user