diff --git a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/IDEContainerContributor.kt b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/IDEContainerContributor.kt index 24cc9ef81..772e5acb4 100644 --- a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/IDEContainerContributor.kt +++ b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/IDEContainerContributor.kt @@ -9,8 +9,8 @@ package net.mamoe.mirai.console.intellij +import net.mamoe.mirai.console.intellij.diagnostics.ContextualParametersChecker import net.mamoe.mirai.console.intellij.diagnostics.PluginDataValuesChecker -import net.mamoe.mirai.console.intellij.diagnostics.PluginDescriptionChecker import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.useInstance import org.jetbrains.kotlin.descriptors.ModuleDescriptor @@ -22,7 +22,7 @@ class IDEContainerContributor : StorageComponentContainerContributor { platform: org.jetbrains.kotlin.platform.TargetPlatform, moduleDescriptor: ModuleDescriptor, ) { - container.useInstance(PluginDescriptionChecker()) + container.useInstance(ContextualParametersChecker()) container.useInstance(PluginDataValuesChecker()) } } \ No newline at end of file diff --git a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/PluginDescriptionChecker.kt b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt similarity index 74% rename from tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/PluginDescriptionChecker.kt rename to tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt index b3f0b3d1c..1a62b1f5f 100644 --- a/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/PluginDescriptionChecker.kt +++ b/tools/intellij-plugin/src/main/kotlin/net/mamoe/mirai/console/intellij/diagnostics/ContextualParametersChecker.kt @@ -24,11 +24,9 @@ import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext import java.util.* /** - * Checks: - * - plugin id - * - plugin name + * Checks paramters with [ResolveContextKind] */ -class PluginDescriptionChecker : DeclarationChecker { +class ContextualParametersChecker : DeclarationChecker { companion object { private val ID_REGEX: Regex = Regex("""([a-zA-Z]+(?:\.[a-zA-Z0-9]+)*)\.([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)""") private val FORBIDDEN_ID_NAMES: Array = arrayOf("main", "console", "plugin", "config", "data") @@ -103,40 +101,5 @@ class PluginDescriptionChecker : DeclarationChecker { fn(argument.asElement(), resolvedConstant)?.let { context.report(it) } } return - /* - when (declaration) { - is KtClassOrObject -> { - // check super type constructor - val superTypeCallEntry = declaration.findChild()?.findChild() ?: return - // val constructorCall = superTypeCallEntry.findChildren()?.resolveToCall() ?: return - val valueArgumentList = superTypeCallEntry.findChild() ?: return - valueArgumentList.arguments.asSequence().mapNotNull(KtValueArgument::getArgumentExpression).forEach { - for (child in it.allChildrenWithSelf) { - if (child is LambdaArgument) { - child.getLambdaExpression()?.bodyExpression?.statements?.forEach { statement -> - if (statement is KtCallExpression) check(statement, context) - } - } - if (child is KtCallExpression) { - check(child, context) - } - } - } - } - else -> { - declaration.children.flatMap { - when (it) { - is KtCallExpression -> listOf(it) - is KtLambdaExpression -> it.bodyExpression?.statements.orEmpty() - else -> emptyList() - } - }.forEach { element -> - if (element is KtDeclaration) { - val desc = element.descriptor ?: return@forEach - check(element, desc, context) - } - } - } - }*/ } } \ No newline at end of file