mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-23 13:50:12 +08:00
Move compiler common to compiler-common module
This commit is contained in:
parent
f37f059634
commit
c1ea2d94ee
@ -57,7 +57,6 @@ dependencies {
|
||||
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}")
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}")
|
||||
compileOnly(files("libs/ide-common.jar"))
|
||||
|
||||
testApi(kotlin("test"))
|
||||
testApi(kotlin("test-junit5"))
|
||||
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2020 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
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.compiler.common.resolve
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Command
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
val COMPOSITE_COMMAND_SUB_COMMAND_FQ_NAME = FqName("net.mamoe.mirai.console.command.CompositeCommand.SubCommand")
|
||||
val SIMPLE_COMMAND_HANDLER_COMMAND_FQ_NAME = FqName("net.mamoe.mirai.console.command.SimpleCommand.Handler")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Plugin
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
val PLUGIN_FQ_NAME = FqName("net.mamoe.mirai.console.plugin.Plugin")
|
||||
val JVM_PLUGIN_DESCRIPTION_FQ_NAME = FqName("net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription")
|
||||
val SIMPLE_JVM_PLUGIN_DESCRIPTION_FQ_NAME = FqName("net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription")
|
@ -14,11 +14,17 @@ import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||
|
||||
/**
|
||||
* Checks:
|
||||
* - plugin id
|
||||
* - plugin name
|
||||
*/
|
||||
class PluginDescriptionChecker : DeclarationChecker {
|
||||
override fun check(
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
context: DeclarationCheckerContext,
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
@ -16,8 +16,8 @@ import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.castSafelyTo
|
||||
import net.mamoe.mirai.console.compiler.common.resolve.PLUGIN_FQ_NAME
|
||||
import net.mamoe.mirai.console.intellij.Icons
|
||||
import net.mamoe.mirai.console.intellij.resolve.Plugin_FQ_NAME
|
||||
import org.jetbrains.kotlin.nj2k.postProcessing.resolve
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtConstructor
|
||||
@ -31,7 +31,7 @@ class PluginMainLineMarkerProvider : LineMarkerProvider {
|
||||
element.parents.filterIsInstance<KtObjectDeclaration>().firstOrNull() ?: return null
|
||||
val kotlinPluginClass =
|
||||
element.resolve().castSafelyTo<KtConstructor<*>>()?.parent?.castSafelyTo<KtClass>() ?: return null
|
||||
if (kotlinPluginClass.allSuperNames.none { it == Plugin_FQ_NAME }) return null
|
||||
if (kotlinPluginClass.allSuperNames.none { it == PLUGIN_FQ_NAME }) return null
|
||||
return Info(getElementForLineMark(objectDeclaration))
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,6 @@ package net.mamoe.mirai.console.intellij.line.marker
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiReferenceExpression
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||
import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.nj2k.postProcessing.resolve
|
||||
@ -31,12 +29,6 @@ internal inline fun <reified E> PsiElement.findParent(): E? = this.parents.filte
|
||||
|
||||
internal val KtClassOrObject.allSuperNames: Sequence<FqName> get() = allSuperTypes.mapNotNull { it.getKotlinFqName() }
|
||||
|
||||
fun PsiReferenceExpression.hasBridgeCalls(): Boolean {
|
||||
val resolved = this.resolve() as? KtLightMethod ?: return false
|
||||
|
||||
TODO()
|
||||
}
|
||||
|
||||
val PsiElement.parents: Sequence<PsiElement>
|
||||
get() {
|
||||
val seed = if (this is PsiFile) null else parent
|
||||
|
@ -9,14 +9,11 @@
|
||||
|
||||
package net.mamoe.mirai.console.intellij.resolve
|
||||
|
||||
import net.mamoe.mirai.console.compiler.common.resolve.COMPOSITE_COMMAND_SUB_COMMAND_FQ_NAME
|
||||
import net.mamoe.mirai.console.compiler.common.resolve.SIMPLE_COMMAND_HANDLER_COMMAND_FQ_NAME
|
||||
import net.mamoe.mirai.console.intellij.line.marker.hasAnnotation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
|
||||
val COMPOSITE_COMMAND_SUB_COMMAND_FQ_NAME = FqName("net.mamoe.mirai.console.command.CompositeCommand.SubCommand")
|
||||
val SIMPLE_COMMAND_HANDLER_COMMAND_FQ_NAME = FqName("net.mamoe.mirai.console.command.SimpleCommand.Handler")
|
||||
|
||||
val Plugin_FQ_NAME = FqName("net.mamoe.mirai.console.plugin.Plugin")
|
||||
|
||||
/**
|
||||
* For CompositeCommand.SubCommand
|
||||
@ -29,4 +26,4 @@ fun KtNamedFunction.isCompositeCommandSubCommand(): Boolean = this.hasAnnotation
|
||||
fun KtNamedFunction.isSimpleCommandHandler(): Boolean = this.hasAnnotation(SIMPLE_COMMAND_HANDLER_COMMAND_FQ_NAME)
|
||||
|
||||
fun KtNamedFunction.isSimpleCommandHandlerOrCompositeCommandSubCommand(): Boolean =
|
||||
this.isSimpleCommandHandler() || this.isCompositeCommandSubCommand()
|
||||
this.isSimpleCommandHandler() || this.isCompositeCommandSubCommand()
|
Loading…
Reference in New Issue
Block a user