diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassFileFactory.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassFileFactory.java index 20336695251..fe212fc70ce 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassFileFactory.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassFileFactory.java @@ -368,4 +368,10 @@ public class ClassFileFactory implements OutputFileCollection { generators.remove(classInternalName + ".class"); } } + + // TODO: remove after cleanin up IDE counterpart + @TestOnly + public List getInputFiles() { + return state.getFiles(); + } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/KotlinCodegenFacade.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/KotlinCodegenFacade.java index 4cb9844411d..49bdea16468 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/KotlinCodegenFacade.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/KotlinCodegenFacade.java @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStat import org.jetbrains.kotlin.psi.KtFile; import java.util.Collection; -import java.util.List; public class KotlinCodegenFacade { public static void compileCorrectFiles( @@ -49,6 +48,12 @@ public class KotlinCodegenFacade { state.getFactory().done(); } + // TODO: remove after cleanin up IDE counterpart + public static void compileCorrectFiles(@NotNull GenerationState state) { + CodegenFactory codegenFactory = state.getCodegenFactory(); + compileCorrectFiles(state.getFiles(), state, codegenFactory != null ? codegenFactory : DefaultCodegenFactory.INSTANCE); + } + public static void generatePackage(@NotNull GenerationState state, @NotNull FqName packageFqName, @NotNull Collection files) { DefaultCodegenFactory.INSTANCE.generatePackage(state, packageFqName, files); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index 9c25e45d419..6ac7712d364 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -79,6 +79,18 @@ class GenerationState private constructor( private val bindingContext: BindingContext, private val configuration: CompilerConfiguration ) { + // TODO: patch IntelliJ project and remove this compatibility c-tor + constructor( + project: Project, + builderFactory: ClassBuilderFactory, + module: ModuleDescriptor, + bindingContext: BindingContext, + files: List, + configuration: CompilerConfiguration + ) : this(project, builderFactory, module, bindingContext, configuration) { + this.files = files + } + private var generateDeclaredClassFilter: GenerateClassFilter = GenerateClassFilter.GENERATE_ALL fun generateDeclaredClassFilter(v: GenerateClassFilter) = apply { generateDeclaredClassFilter = v } @@ -125,6 +137,12 @@ class GenerationState private constructor( val isIncrementalCompilation: Boolean = configuration.getBoolean(CommonConfigurationKeys.INCREMENTAL_COMPILATION) + // TODO: remove after cleanin up IDE counterpart + private var files: List? = null + private var codegenFactory: CodegenFactory? = null + fun codegenFactory(v: CodegenFactory) = + apply { codegenFactory = v } + fun build() = GenerationState( project, builderFactory, module, bindingContext, configuration, @@ -133,7 +151,10 @@ class GenerationState private constructor( jvmBackendClassResolver, isIrBackend, ignoreErrors, diagnosticReporter ?: DiagnosticReporterFactory.createReporter(), isIncrementalCompilation - ) + ).also { + it.files = files + it.codegenFactory = codegenFactory + } } abstract class GenerateClassFilter { @@ -170,6 +191,10 @@ class GenerationState private constructor( LockBasedStorageManager.NO_LOCKS, languageVersionSettings, JavaDeprecationSettings ) + // TODO: remove after cleanin up IDE counterpart + var files: List? = null + var codegenFactory: CodegenFactory? = null + init { val icComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS) if (icComponents != null) {