formatting clean up
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
e101f88b50
commit
2f3ff10204
@@ -37,32 +37,32 @@ import kotlin.collections.HashSet
|
|||||||
const val DELETE_MODULE_FILE_PROPERTY = "kotlin.delete.module.file.after.build"
|
const val DELETE_MODULE_FILE_PROPERTY = "kotlin.delete.module.file.after.build"
|
||||||
|
|
||||||
fun makeModuleFile(
|
fun makeModuleFile(
|
||||||
name: String,
|
name: String,
|
||||||
isTest: Boolean,
|
isTest: Boolean,
|
||||||
outputDir: File,
|
outputDir: File,
|
||||||
sourcesToCompile: Iterable<File>,
|
sourcesToCompile: Iterable<File>,
|
||||||
commonSources: Iterable<File>,
|
commonSources: Iterable<File>,
|
||||||
javaSourceRoots: Iterable<JvmSourceRoot>,
|
javaSourceRoots: Iterable<JvmSourceRoot>,
|
||||||
classpath: Iterable<File>,
|
classpath: Iterable<File>,
|
||||||
friendDirs: Iterable<File>
|
friendDirs: Iterable<File>
|
||||||
): File {
|
): File {
|
||||||
val builder = KotlinModuleXmlBuilder()
|
val builder = KotlinModuleXmlBuilder()
|
||||||
builder.addModule(
|
builder.addModule(
|
||||||
name,
|
name,
|
||||||
outputDir.absolutePath,
|
outputDir.absolutePath,
|
||||||
// important to transform file to absolute paths,
|
// important to transform file to absolute paths,
|
||||||
// otherwise compiler will use module file's parent as base path (a temporary file; see below)
|
// otherwise compiler will use module file's parent as base path (a temporary file; see below)
|
||||||
// (see org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.getAbsolutePaths)
|
// (see org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.getAbsolutePaths)
|
||||||
sourcesToCompile.map { it.absoluteFile },
|
sourcesToCompile.map { it.absoluteFile },
|
||||||
javaSourceRoots,
|
javaSourceRoots,
|
||||||
classpath,
|
classpath,
|
||||||
commonSources.map { it.absoluteFile },
|
commonSources.map { it.absoluteFile },
|
||||||
null,
|
null,
|
||||||
"java-production",
|
"java-production",
|
||||||
isTest,
|
isTest,
|
||||||
// this excludes the output directories from the class path, to be removed for true incremental compilation
|
// this excludes the output directories from the class path, to be removed for true incremental compilation
|
||||||
setOf(outputDir),
|
setOf(outputDir),
|
||||||
friendDirs
|
friendDirs
|
||||||
)
|
)
|
||||||
|
|
||||||
val scriptFile = File.createTempFile("kjps", sanitizeJavaIdentifier(name) + ".script.xml")
|
val scriptFile = File.createTempFile("kjps", sanitizeJavaIdentifier(name) + ".script.xml")
|
||||||
@@ -83,9 +83,9 @@ private fun sanitizeJavaIdentifier(string: String) =
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun makeCompileServices(
|
fun makeCompileServices(
|
||||||
incrementalCaches: Map<TargetId, IncrementalCache>,
|
incrementalCaches: Map<TargetId, IncrementalCache>,
|
||||||
lookupTracker: LookupTracker,
|
lookupTracker: LookupTracker,
|
||||||
compilationCanceledStatus: CompilationCanceledStatus?
|
compilationCanceledStatus: CompilationCanceledStatus?
|
||||||
): Services =
|
): Services =
|
||||||
with(Services.Builder()) {
|
with(Services.Builder()) {
|
||||||
register(LookupTracker::class.java, lookupTracker)
|
register(LookupTracker::class.java, lookupTracker)
|
||||||
@@ -105,12 +105,14 @@ fun updateIncrementalCache(
|
|||||||
for (generatedFile in generatedFiles) {
|
for (generatedFile in generatedFiles) {
|
||||||
when {
|
when {
|
||||||
generatedFile is GeneratedJvmClass -> cache.saveFileToCache(generatedFile, changesCollector)
|
generatedFile is GeneratedJvmClass -> cache.saveFileToCache(generatedFile, changesCollector)
|
||||||
generatedFile.outputFile.isModuleMappingFile() -> cache.saveModuleMappingToCache(generatedFile.sourceFiles, generatedFile.outputFile)
|
generatedFile.outputFile.isModuleMappingFile() -> cache.saveModuleMappingToCache(
|
||||||
|
generatedFile.sourceFiles,
|
||||||
|
generatedFile.outputFile
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
javaChangesTracker?.javaClassesUpdates?.forEach {
|
javaChangesTracker?.javaClassesUpdates?.forEach { (source, serializedJavaClass) ->
|
||||||
(source, serializedJavaClass) ->
|
|
||||||
cache.saveJavaClassProto(source, serializedJavaClass, changesCollector)
|
cache.saveJavaClassProto(source, serializedJavaClass, changesCollector)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,9 +120,9 @@ fun updateIncrementalCache(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun LookupStorage.update(
|
fun LookupStorage.update(
|
||||||
lookupTracker: LookupTracker,
|
lookupTracker: LookupTracker,
|
||||||
filesToCompile: Iterable<File>,
|
filesToCompile: Iterable<File>,
|
||||||
removedFiles: Iterable<File>
|
removedFiles: Iterable<File>
|
||||||
) {
|
) {
|
||||||
if (lookupTracker !is LookupTrackerImpl) throw AssertionError("Lookup tracker is expected to be LookupTrackerImpl, got ${lookupTracker::class.java}")
|
if (lookupTracker !is LookupTrackerImpl) throw AssertionError("Lookup tracker is expected to be LookupTrackerImpl, got ${lookupTracker::class.java}")
|
||||||
|
|
||||||
@@ -130,8 +132,8 @@ fun LookupStorage.update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class DirtyData(
|
data class DirtyData(
|
||||||
val dirtyLookupSymbols: Collection<LookupSymbol> = emptyList(),
|
val dirtyLookupSymbols: Collection<LookupSymbol> = emptyList(),
|
||||||
val dirtyClassesFqNames: Collection<FqName> = emptyList()
|
val dirtyClassesFqNames: Collection<FqName> = emptyList()
|
||||||
)
|
)
|
||||||
|
|
||||||
fun ChangesCollector.getDirtyData(
|
fun ChangesCollector.getDirtyData(
|
||||||
@@ -213,8 +215,8 @@ fun mapClassesFqNamesToFiles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun withSubtypes(
|
fun withSubtypes(
|
||||||
typeFqName: FqName,
|
typeFqName: FqName,
|
||||||
caches: Iterable<IncrementalCacheCommon>
|
caches: Iterable<IncrementalCacheCommon>
|
||||||
): Set<FqName> {
|
): Set<FqName> {
|
||||||
val types = LinkedList(listOf(typeFqName))
|
val types = LinkedList(listOf(typeFqName))
|
||||||
val subtypes = hashSetOf<FqName>()
|
val subtypes = hashSetOf<FqName>()
|
||||||
@@ -223,9 +225,9 @@ fun withSubtypes(
|
|||||||
val unprocessedType = types.pollFirst()
|
val unprocessedType = types.pollFirst()
|
||||||
|
|
||||||
caches.asSequence()
|
caches.asSequence()
|
||||||
.flatMap { it.getSubtypesOf(unprocessedType) }
|
.flatMap { it.getSubtypesOf(unprocessedType) }
|
||||||
.filter { it !in subtypes }
|
.filter { it !in subtypes }
|
||||||
.forEach { types.addLast(it) }
|
.forEach { types.addLast(it) }
|
||||||
|
|
||||||
subtypes.add(unprocessedType)
|
subtypes.add(unprocessedType)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user