[FIR] Part 1. Group checkers by the MPP kind
This commit introduces MppChecker kind, which represents the new property of checkers - `MppCheckerKind.Common` means that this checker should run from the same session to which corresponding declaration belongs - `MppCheckerKind.Platform` means that in case of MPP compilation this checker should run with session of leaf platform module for sources of all modules An example of a platform checker is a checker that checks class scopes and reports ABSTRACT_NOT_IMPLEMENTED and similar diagnostics. If some regular class in the common module contains expect supertypes, the checker should consider the actualization of those supertypes to get a complete type scope ^KT-58881
This commit is contained in:
committed by
Nikolay Lunyak
parent
ff063f553e
commit
727d2f46f8
+11
-5
@@ -15,6 +15,8 @@ private typealias Fqn = String
|
||||
|
||||
private const val CHECKERS_COMPONENT_INTERNAL_ANNOTATION = "@CheckersComponentInternal"
|
||||
private const val CHECKERS_COMPONENT_INTERNAL_FQN = "org.jetbrains.kotlin.fir.analysis.CheckersComponentInternal"
|
||||
private const val MPP_CHECKER_KIND_FQN = "org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind"
|
||||
private const val MPP_CHECKER_WITH_KIND_FQN = "org.jetbrains.kotlin.fir.analysis.checkers.FirCheckerWithMppKind"
|
||||
|
||||
class Generator(
|
||||
private val configuration: CheckersConfiguration,
|
||||
@@ -90,10 +92,13 @@ class Generator(
|
||||
val filename = "${composedComponentName}.kt"
|
||||
generationPath.resolve(filename).writeToFileUsingSmartPrinterIfFileContentChanged {
|
||||
printPackageAndCopyright()
|
||||
printImports()
|
||||
printImports(MPP_CHECKER_KIND_FQN, MPP_CHECKER_WITH_KIND_FQN)
|
||||
printGeneratedMessage()
|
||||
println("class $composedComponentName : $checkersComponentName() {")
|
||||
println("class $composedComponentName(val predicate: (FirCheckerWithMppKind) -> Boolean) : $checkersComponentName() {")
|
||||
withIndent {
|
||||
println("constructor(mppKind: MppCheckerKind) : this({ it.mppKind == mppKind })")
|
||||
println()
|
||||
|
||||
// public overrides
|
||||
for (alias in configuration.aliases.values) {
|
||||
println("override ${alias.valDeclaration}")
|
||||
@@ -123,10 +128,10 @@ class Generator(
|
||||
println("fun register(checkers: $checkersComponentName) {")
|
||||
withIndent {
|
||||
for (alias in configuration.aliases.values) {
|
||||
println("_${alias.fieldName} += checkers.${alias.fieldName}")
|
||||
println("checkers.${alias.fieldName}.filterTo(_${alias.fieldName}, predicate)")
|
||||
}
|
||||
for (fieldName in configuration.additionalCheckers.keys) {
|
||||
println("_$fieldName += checkers.$fieldName")
|
||||
println("checkers.$fieldName.filterTo(_$fieldName, predicate)")
|
||||
}
|
||||
}
|
||||
println("}")
|
||||
@@ -141,10 +146,11 @@ class Generator(
|
||||
println()
|
||||
}
|
||||
|
||||
private fun SmartPrinter.printImports() {
|
||||
private fun SmartPrinter.printImports(vararg additionalImports: String) {
|
||||
val imports = buildList {
|
||||
addAll(configuration.additionalCheckers.values)
|
||||
add(CHECKERS_COMPONENT_INTERNAL_FQN)
|
||||
addAll(additionalImports)
|
||||
}.sorted()
|
||||
|
||||
for (fqn in imports) {
|
||||
|
||||
Reference in New Issue
Block a user