[Frontend] Make DiagnosticSuppressor a project-level extension

Originally it was an application-level component, which caused non-trivial
  logic and cognitive load to carefully handle those extensions to avoid
  memory leaks.

6740a596 introduced a way to easily register `DiagnosticSuppressor` to
  project, and this commit continues this work, making it a proper
  project-level extension

A lot of changes caused by the fact, that this extension is needed to be
  obtained from `BindingContext` (see `BindingContextSuppressCache` and
  its usages), so almost all changes are introducing `Project` to
  `BindingContext`

^KT-66449 Fixed
This commit is contained in:
Dmitriy Novozhilov
2024-03-08 08:52:28 +02:00
committed by Space Team
parent a552238874
commit d352cc9d96
45 changed files with 165 additions and 127 deletions
@@ -186,7 +186,7 @@ object KotlinToJVMBytecodeCompiler {
factory,
input,
fir2IrAndIrActualizerResult.irModuleFragment.descriptor,
NoScopeRecordCliBindingTrace().bindingContext,
NoScopeRecordCliBindingTrace(project).bindingContext,
FirJvmBackendClassResolver(fir2IrAndIrActualizerResult.components),
FirJvmBackendExtension(
fir2IrAndIrActualizerResult.components,
@@ -383,7 +383,7 @@ object KotlinToJVMBytecodeCompiler {
TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
project,
sourceFiles,
NoScopeRecordCliBindingTrace(),
NoScopeRecordCliBindingTrace(project),
environment.configuration,
environment::createPackagePartProvider,
sourceModuleSearchScope = scope,
@@ -209,10 +209,12 @@ fun generateCodeFromIr(
input.configuration,
input.configuration.get(CLIConfigurationKeys.PHASE_CONFIG),
)
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
val project = (environment.projectEnvironment as VfsBasedProjectEnvironment).project
val dummyBindingContext = NoScopeRecordCliBindingTrace(project).bindingContext
val generationState = GenerationState.Builder(
(environment.projectEnvironment as VfsBasedProjectEnvironment).project, ClassBuilderFactories.BINARIES,
project, ClassBuilderFactories.BINARIES,
input.irModuleFragment.descriptor, dummyBindingContext, input.configuration
).targetId(
input.targetId