Drop several more parameters of GenerationState's constructor
INCREMENTAL_COMPILATION_COMPONENTS and DECLARATIONS_JSON_PATH are already in the configuration, and Progress was unused
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Function;
|
||||
@@ -76,12 +75,13 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
public ClassBuilder newVisitor(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
@NotNull Type asmType,
|
||||
@NotNull Collection<? extends PsiFile> sourceFiles) {
|
||||
String outputFilePath = asmType.getInternalName() + ".class";
|
||||
List<File> ioSourceFiles = toIoFilesIgnoringNonPhysical(sourceFiles);
|
||||
state.getProgress().reportOutput(ioSourceFiles, new File(outputFilePath));
|
||||
@NotNull Collection<? extends PsiFile> sourceFiles
|
||||
) {
|
||||
ClassBuilder answer = builderFactory.newClassBuilder(origin);
|
||||
generators.put(outputFilePath, new ClassBuilderAndSourceFileList(answer, ioSourceFiles));
|
||||
generators.put(
|
||||
asmType.getInternalName() + ".class",
|
||||
new ClassBuilderAndSourceFileList(answer, toIoFilesIgnoringNonPhysical(sourceFiles))
|
||||
);
|
||||
return answer;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,6 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
}
|
||||
|
||||
if (builder.getPackagePartsCount() != 0) {
|
||||
state.getProgress().reportOutput(packagePartSourceFiles, new File(outputFilePath));
|
||||
generators.put(outputFilePath, new OutAndSourceFileList(CollectionsKt.toList(packagePartSourceFiles)) {
|
||||
@Override
|
||||
public byte[] asBytes(ClassBuilderFactory factory) {
|
||||
@@ -225,7 +224,7 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
|
||||
@NotNull
|
||||
private static List<File> toIoFilesIgnoringNonPhysical(@NotNull Collection<? extends PsiFile> psiFiles) {
|
||||
List<File> result = Lists.newArrayList();
|
||||
List<File> result = new ArrayList<File>(psiFiles.size());
|
||||
for (PsiFile psiFile : psiFiles) {
|
||||
VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||
// We ignore non-physical files here, because this code is needed to tell the make what inputs affect which outputs
|
||||
|
||||
@@ -33,9 +33,7 @@ fun List<PackageParts>.addCompiledPartsAndSort(state: GenerationState): List<Pac
|
||||
addCompiledParts(state).sortedBy { it.packageFqName }
|
||||
|
||||
private fun List<PackageParts>.addCompiledParts(state: GenerationState): List<PackageParts> {
|
||||
if (state.incrementalCompilationComponents == null || state.targetId == null) return this
|
||||
|
||||
val incrementalCache = state.incrementalCompilationComponents.getIncrementalCache(state.targetId)
|
||||
val incrementalCache = state.getIncrementalCacheForThisTarget() ?: return this
|
||||
val moduleMappingData = incrementalCache.getModuleMappingData() ?: return this
|
||||
|
||||
val mapping = ModuleMapping.create(moduleMappingData)
|
||||
|
||||
@@ -32,8 +32,6 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents;
|
||||
import org.jetbrains.kotlin.modules.TargetId;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
@@ -910,12 +908,8 @@ public class InlineCodegen extends CallGenerator {
|
||||
@NotNull JvmMethodSignature jvmSignature,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
IncrementalCompilationComponents incrementalCompilationComponents = state.getIncrementalCompilationComponents();
|
||||
TargetId targetId = state.getTargetId();
|
||||
|
||||
if (incrementalCompilationComponents == null || targetId == null) return;
|
||||
|
||||
IncrementalCache incrementalCache = incrementalCompilationComponents.getIncrementalCache(targetId);
|
||||
IncrementalCache incrementalCache = state.getIncrementalCacheForThisTarget();
|
||||
if (incrementalCache == null) return;
|
||||
String classFilePath = InlineCodegenUtilsKt.getClassFilePath(sourceDescriptor, state.getTypeMapper(), incrementalCache);
|
||||
String sourceFilePath = InlineCodegenUtilsKt.getSourceFilePath(targetDescriptor);
|
||||
incrementalCache.registerInline(classFilePath, jvmSignature.toString(), sourceFilePath);
|
||||
@@ -925,6 +919,5 @@ public class InlineCodegen extends CallGenerator {
|
||||
public void reorderArgumentsIfNeeded(
|
||||
@NotNull List<ArgumentAndDeclIndex> actualArgsWithDeclIndex, @NotNull List<? extends Type> valueParameterTypes
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
@@ -59,15 +59,12 @@ class GenerationState @JvmOverloads constructor(
|
||||
val obsoleteMultifileClasses: Collection<FqName> = emptySet(),
|
||||
// for PackageCodegen in incremental compilation mode
|
||||
val targetId: TargetId? = null,
|
||||
moduleName: String? = null,
|
||||
moduleName: String? = configuration.get(JVMConfigurationKeys.MODULE_NAME),
|
||||
// 'outDirectory' is a hack to correctly determine if a compiled class is from the same module as the callee during
|
||||
// partial compilation. Module chunks are treated as a single module.
|
||||
// TODO: get rid of it with the proper module infrastructure
|
||||
val outDirectory: File? = null,
|
||||
val incrementalCompilationComponents: IncrementalCompilationComponents? = null,
|
||||
val progress: Progress = Progress.DEAF,
|
||||
private val onIndependentPartCompilationEnd: GenerationStateEventCallback = GenerationStateEventCallback.DO_NOTHING,
|
||||
dumpBinarySignatureMappingTo: File? = null
|
||||
private val onIndependentPartCompilationEnd: GenerationStateEventCallback = GenerationStateEventCallback.DO_NOTHING
|
||||
) {
|
||||
abstract class GenerateClassFilter {
|
||||
abstract fun shouldAnnotateClass(processingClassOrObject: KtClassOrObject): Boolean
|
||||
@@ -91,10 +88,10 @@ class GenerationState @JvmOverloads constructor(
|
||||
val fileClassesProvider: CodegenFileClassesProvider = CodegenFileClassesProvider()
|
||||
val inlineCache: InlineCache = InlineCache()
|
||||
|
||||
private fun getIncrementalCacheForThisTarget() =
|
||||
if (incrementalCompilationComponents != null && targetId != null)
|
||||
incrementalCompilationComponents.getIncrementalCache(targetId)
|
||||
else null
|
||||
fun getIncrementalCacheForThisTarget(): IncrementalCache? =
|
||||
configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)?.let { components ->
|
||||
targetId?.let { components.getIncrementalCache(it) }
|
||||
}
|
||||
|
||||
val extraJvmDiagnosticsTrace: BindingTrace = DelegatingBindingTrace(bindingContext, false, "For extra diagnostics in ${this.javaClass}")
|
||||
private val interceptedBuilderFactory: ClassBuilderFactory
|
||||
@@ -150,7 +147,8 @@ class GenerationState @JvmOverloads constructor(
|
||||
getIncrementalCacheForThisTarget(),
|
||||
this.moduleName).apply { duplicateSignatureFactory = this } },
|
||||
{ BuilderFactoryForDuplicateClassNameDiagnostics(it, diagnostics) },
|
||||
{ dumpBinarySignatureMappingTo?.let { destination -> SignatureDumpingBuilderFactory(it, destination) } ?: it }
|
||||
{ configuration.get(JVMConfigurationKeys.DECLARATIONS_JSON_PATH)
|
||||
?.let { destination -> SignatureDumpingBuilderFactory(it, File(destination)) } ?: it }
|
||||
)
|
||||
.wrapWith(ClassBuilderInterceptorExtension.getInstances(project)) { builderFactory, extension ->
|
||||
extension.interceptClassBuilderFactory(builderFactory, bindingContext, diagnostics)
|
||||
@@ -212,4 +210,4 @@ private fun ClassBuilderFactory.wrapWith(vararg wrappers: (ClassBuilderFactory)
|
||||
wrappers.fold(this) { builderFactory, wrapper -> wrapper(builderFactory) }
|
||||
|
||||
private inline fun <T> ClassBuilderFactory.wrapWith(elements: Iterable<T>, wrapper: (ClassBuilderFactory, T) -> ClassBuilderFactory): ClassBuilderFactory =
|
||||
elements.fold(this, wrapper)
|
||||
elements.fold(this, wrapper)
|
||||
|
||||
Reference in New Issue
Block a user