mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-11 02:50:15 +08:00
Rename PluginDescriptionChecker.kt to ContextualParametersChecker.kt for further extensibility
This commit is contained in:
parent
16598ee8ec
commit
c1f1b6954a
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.console.intellij
|
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.PluginDataValuesChecker
|
||||||
import net.mamoe.mirai.console.intellij.diagnostics.PluginDescriptionChecker
|
|
||||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||||
import org.jetbrains.kotlin.container.useInstance
|
import org.jetbrains.kotlin.container.useInstance
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
@ -22,7 +22,7 @@ class IDEContainerContributor : StorageComponentContainerContributor {
|
|||||||
platform: org.jetbrains.kotlin.platform.TargetPlatform,
|
platform: org.jetbrains.kotlin.platform.TargetPlatform,
|
||||||
moduleDescriptor: ModuleDescriptor,
|
moduleDescriptor: ModuleDescriptor,
|
||||||
) {
|
) {
|
||||||
container.useInstance(PluginDescriptionChecker())
|
container.useInstance(ContextualParametersChecker())
|
||||||
container.useInstance(PluginDataValuesChecker())
|
container.useInstance(PluginDataValuesChecker())
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,11 +24,9 @@ import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks:
|
* Checks paramters with [ResolveContextKind]
|
||||||
* - plugin id
|
|
||||||
* - plugin name
|
|
||||||
*/
|
*/
|
||||||
class PluginDescriptionChecker : DeclarationChecker {
|
class ContextualParametersChecker : DeclarationChecker {
|
||||||
companion object {
|
companion object {
|
||||||
private val ID_REGEX: Regex = Regex("""([a-zA-Z]+(?:\.[a-zA-Z0-9]+)*)\.([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)""")
|
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<String> = arrayOf("main", "console", "plugin", "config", "data")
|
private val FORBIDDEN_ID_NAMES: Array<String> = arrayOf("main", "console", "plugin", "config", "data")
|
||||||
@ -103,40 +101,5 @@ class PluginDescriptionChecker : DeclarationChecker {
|
|||||||
fn(argument.asElement(), resolvedConstant)?.let { context.report(it) }
|
fn(argument.asElement(), resolvedConstant)?.let { context.report(it) }
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
/*
|
|
||||||
when (declaration) {
|
|
||||||
is KtClassOrObject -> {
|
|
||||||
// check super type constructor
|
|
||||||
val superTypeCallEntry = declaration.findChild<KtSuperTypeList>()?.findChild<KtSuperTypeCallEntry>() ?: return
|
|
||||||
// val constructorCall = superTypeCallEntry.findChildren<KtConstructorCalleeExpression>()?.resolveToCall() ?: return
|
|
||||||
val valueArgumentList = superTypeCallEntry.findChild<KtValueArgumentList>() ?: 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user