Explorar el Código

Move compiler common to compiler-common module

Him188 hace 5 años
padre
commit
c1ea2d94ee

+ 0 - 1
tools/compiler-common/build.gradle.kts

@@ -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"))

+ 27 - 0
tools/compiler-common/src/main/kotlin/net/mamoe/mirai/console/compiler/common/resolve/MiraiConsoleTypes.kt

@@ -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")

+ 6 - 0
tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/PluginDescriptionChecker.kt

@@ -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,
     ) {
+
     }
 }

+ 2 - 2
tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/line/marker/PluginMainLineMarkerProvider.kt

@@ -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))
     }
 

+ 0 - 8
tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/line/marker/util.kt

@@ -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

+ 3 - 6
tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/psiResolve.kt → tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/resolve/resolveIdea.kt

@@ -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()