Temporary restore generation state and related PSI-based APIs

Changes required on IDE plugin side before applying API changes.
This commit is contained in:
Ilya Chernikov
2022-02-25 12:08:31 +01:00
committed by teamcity
parent 03cbfea737
commit 27a3c77174
3 changed files with 38 additions and 2 deletions
@@ -368,4 +368,10 @@ public class ClassFileFactory implements OutputFileCollection {
generators.remove(classInternalName + ".class");
}
}
// TODO: remove after cleanin up IDE counterpart
@TestOnly
public List<KtFile> getInputFiles() {
return state.getFiles();
}
}
@@ -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<KtFile> files) {
DefaultCodegenFactory.INSTANCE.generatePackage(state, packageFqName, files);
}
@@ -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<KtFile>,
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<KtFile>? = 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<KtFile>? = null
var codegenFactory: CodegenFactory? = null
init {
val icComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
if (icComponents != null) {