@Nullable
  private static AnalyzeExhaust analyze(
      final K2JVMCompileEnvironmentConfiguration configuration, boolean stubs) {
    final JetCoreEnvironment environment = configuration.getEnvironment();
    AnalyzerWithCompilerReport analyzerWithCompilerReport =
        new AnalyzerWithCompilerReport(configuration.getMessageCollector());
    final Predicate<PsiFile> filesToAnalyzeCompletely =
        stubs ? Predicates.<PsiFile>alwaysFalse() : Predicates.<PsiFile>alwaysTrue();
    analyzerWithCompilerReport.analyzeAndReport(
        new Function0<AnalyzeExhaust>() {
          @NotNull
          @Override
          public AnalyzeExhaust invoke() {
            return AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
                environment.getProject(),
                environment.getSourceFiles(),
                filesToAnalyzeCompletely,
                JetControlFlowDataTraceFactory.EMPTY,
                configuration.getEnvironment().getCompilerDependencies());
          }
        },
        environment.getSourceFiles());

    return analyzerWithCompilerReport.hasErrors()
        ? null
        : analyzerWithCompilerReport.getAnalyzeExhaust();
  }