From 6c7178349851f48fb7eb816e717ebd2c2bdb9962 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 29 Jan 2021 12:43:42 +0800 Subject: [PATCH] Fix CommandDeclarationChecker --- .../diagnostics/CommandDeclarationChecker.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/intellij-plugin/src/diagnostics/CommandDeclarationChecker.kt b/tools/intellij-plugin/src/diagnostics/CommandDeclarationChecker.kt index be26d1a98..6965c23f4 100644 --- a/tools/intellij-plugin/src/diagnostics/CommandDeclarationChecker.kt +++ b/tools/intellij-plugin/src/diagnostics/CommandDeclarationChecker.kt @@ -12,6 +12,8 @@ package net.mamoe.mirai.console.intellij.diagnostics import net.mamoe.mirai.console.compiler.common.diagnostics.MiraiConsoleErrors.ILLEGAL_COMMAND_DECLARATION_RECEIVER import net.mamoe.mirai.console.compiler.common.resolve.COMMAND_SENDER_FQ_NAME import net.mamoe.mirai.console.intellij.resolve.hasSuperType +import net.mamoe.mirai.console.intellij.resolve.isCompositeCommandSubCommand +import net.mamoe.mirai.console.intellij.resolve.isSimpleCommandHandler import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.psi.KtDeclaration @@ -23,16 +25,15 @@ class CommandDeclarationChecker : DeclarationChecker { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { if (declaration !is KtNamedFunction) return - // exclusive checks - // currently no checks -// when { -// declaration.isSimpleCommandHandler() -> { -// } -// -// declaration.isCompositeCommandSubCommand() -> { -// } -// else -> return -// } + // exclusive checks or return + when { + declaration.isSimpleCommandHandler() -> { + } + + declaration.isCompositeCommandSubCommand() -> { + } + else -> return + } // common checks checkCommandReceiverParameter(declaration)?.let { context.report(it) }