@Nullable private static AnalysisResult analyze( @NotNull final KotlinCoreEnvironment environment, @Nullable String targetDescription) { MessageCollector collector = environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); assert collector != null; long analysisStart = PerformanceCounter.Companion.currentTime(); AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(collector); analyzerWithCompilerReport.analyzeAndReport( environment.getSourceFiles(), new Function0<AnalysisResult>() { @NotNull @Override public AnalysisResult invoke() { BindingTrace sharedTrace = new CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(); ModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule( environment.getProject(), ModuleNameKt.getModuleName(environment)); return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationWithCustomContext( moduleContext, environment.getSourceFiles(), sharedTrace, environment.getConfiguration().get(JVMConfigurationKeys.MODULES), environment .getConfiguration() .get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS), new JvmPackagePartProvider(environment)); } }); long analysisNanos = PerformanceCounter.Companion.currentTime() - analysisStart; String message = "ANALYZE: " + environment.getSourceFiles().size() + " files (" + environment.getSourceLinesOfCode() + " lines) " + (targetDescription != null ? targetDescription : "") + "in " + TimeUnit.NANOSECONDS.toMillis(analysisNanos) + " ms"; K2JVMCompiler.Companion.reportPerf(environment.getConfiguration(), message); AnalysisResult result = analyzerWithCompilerReport.getAnalysisResult(); assert result != null : "AnalysisResult should be non-null, compiling: " + environment.getSourceFiles(); CompilerPluginContext context = new CompilerPluginContext( environment.getProject(), result.getBindingContext(), environment.getSourceFiles()); for (CompilerPlugin plugin : environment.getConfiguration().getList(CLIConfigurationKeys.COMPILER_PLUGINS)) { plugin.processFiles(context); } return analyzerWithCompilerReport.hasErrors() ? null : result; }