[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:
Dmitriy Novozhilov
2024-01-08 14:37:30 +02:00
committed by Nikolay Lunyak
parent ff063f553e
commit 727d2f46f8
338 changed files with 1216 additions and 728 deletions
@@ -8,7 +8,8 @@ package org.jetbrains.kotlin.fir.pipeline
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
import org.jetbrains.kotlin.diagnostics.impl.BaseDiagnosticsCollector
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector
import org.jetbrains.kotlin.fir.analysis.checkers.MppCheckerKind
import org.jetbrains.kotlin.fir.analysis.collectors.components.DiagnosticComponentsFactory
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveProcessor
@@ -23,9 +24,10 @@ fun FirSession.runResolution(firFiles: List<FirFile>): Pair<ScopeSession, List<F
fun FirSession.runCheckers(
scopeSession: ScopeSession,
firFiles: List<FirFile>,
reporter: BaseDiagnosticsCollector
reporter: BaseDiagnosticsCollector,
mppCheckerKind: MppCheckerKind = TODO()
): Map<FirFile, List<KtDiagnostic>> {
val collector = FirDiagnosticsCollector.create(this, scopeSession)
val collector = DiagnosticComponentsFactory.create(this, scopeSession, mppCheckerKind)
collector.collectDiagnosticsInSettings(reporter)
for (file in firFiles) {
withFileAnalysisExceptionWrapping(file) {