New IC: add processing changes for constants

This commit is contained in:
Zalim Bashorov
2015-11-18 19:22:32 +03:00
parent e33e31ad16
commit ced23c02bd
5 changed files with 140 additions and 10 deletions
@@ -160,7 +160,7 @@ open class IncrementalCacheImpl<Target>(
packagePartMap.addPackagePart(className)
protoMap.process(kotlinClass, isPackage = true) +
constantsMap.process(kotlinClass) +
constantsMap.process(kotlinClass, isPackage = true) +
inlineFunctionsMap.process(kotlinClass, isPackage = true)
}
KotlinClassHeader.Kind.MULTIFILE_CLASS -> {
@@ -175,7 +175,7 @@ open class IncrementalCacheImpl<Target>(
classFqNameToSourceMap.remove(className.fqNameForClassNameWithoutDollars)
// TODO NO_CHANGES? (delegates only)
constantsMap.process(kotlinClass) +
constantsMap.process(kotlinClass, isPackage = true) +
inlineFunctionsMap.process(kotlinClass, isPackage = true)
}
KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> {
@@ -184,7 +184,7 @@ open class IncrementalCacheImpl<Target>(
partToMultifileFacade.set(className.internalName, header.multifileClassName!!)
protoMap.process(kotlinClass, isPackage = true) +
constantsMap.process(kotlinClass) +
constantsMap.process(kotlinClass, isPackage = true) +
inlineFunctionsMap.process(kotlinClass, isPackage = true)
}
KotlinClassHeader.Kind.CLASS -> {
@@ -192,7 +192,7 @@ open class IncrementalCacheImpl<Target>(
addToClassStorage(kotlinClass, sourceFiles.first())
protoMap.process(kotlinClass, isPackage = false) +
constantsMap.process(kotlinClass) +
constantsMap.process(kotlinClass, isPackage = true) +
inlineFunctionsMap.process(kotlinClass, isPackage = false)
}
else -> CompilationResult.NO_CHANGES
@@ -426,11 +426,11 @@ open class IncrementalCacheImpl<Target>(
operator fun contains(className: JvmClassName): Boolean =
className.internalName in storage
fun process(kotlinClass: LocalFileKotlinClass): CompilationResult {
return put(kotlinClass.className, getConstantsMap(kotlinClass.fileContents))
fun process(kotlinClass: LocalFileKotlinClass, isPackage: Boolean): CompilationResult {
return put(kotlinClass.className, getConstantsMap(kotlinClass.fileContents), isPackage)
}
private fun put(className: JvmClassName, constantsMap: Map<String, Any>?): CompilationResult {
private fun put(className: JvmClassName, constantsMap: Map<String, Any>?, isPackage: Boolean): CompilationResult {
val key = className.internalName
val oldMap = storage[key]
@@ -440,14 +440,30 @@ open class IncrementalCacheImpl<Target>(
storage[key] = constantsMap
}
else {
storage.remove(key)
remove(className)
}
return CompilationResult(constantsChanged = true)
val changes =
if (!IncrementalCompilation.isExperimental() ||
constantsMap == null || constantsMap.isEmpty() ||
oldMap == null || oldMap.isEmpty()
) {
emptySequence<ChangeInfo>()
}
else {
// we need only changed constants everything other should be covered by diff
val changedNames = oldMap.filter { constantsMap.containsKey(it.key) && constantsMap[it.key] != it.value }.map { it.key }
val fqName = if (isPackage) className.packageFqName else className.fqNameForClassNameWithoutDollars
sequenceOf(ChangeInfo.MembersChanged(fqName, changedNames))
}
return CompilationResult(constantsChanged = true, changes = changes)
}
fun remove(className: JvmClassName) {
put(className, null)
storage.remove(className.internalName)
}
override fun dumpValue(value: Map<String, Any>): String =
@@ -0,0 +1,24 @@
================ Step #1 =================
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/constant/ConstantKt.class
End of files
Compiling files:
src/constant.kt
End of files
Marked as dirty by Kotlin:
src/usage.kt
Exit code: ADDITIONAL_PASS_REQUIRED
------------------------------------------
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/constant/ConstantKt.class
out/production/module/usage/UsageKt.class
End of files
Compiling files:
src/constant.kt
src/usage.kt
End of files
Exit code: OK
------------------------------------------
@@ -0,0 +1,30 @@
================ Step #1 =================
Cleaning output files:
out/production/module1/META-INF/module1.kotlin_module
out/production/module1/test/Module1_constKt.class
End of files
Compiling files:
module1/src/module1_const.kt
End of files
Marked as dirty by Kotlin:
module2/src/module2_usage.kt
Exit code: ADDITIONAL_PASS_REQUIRED
------------------------------------------
Cleaning output files:
out/production/module1/META-INF/module1.kotlin_module
out/production/module1/test/Module1_constKt.class
End of files
Compiling files:
module1/src/module1_const.kt
End of files
Exit code: OK
------------------------------------------
Cleaning output files:
out/production/module2/usage/Usage.class
End of files
Compiling files:
module2/src/module2_usage.kt
End of files
Exit code: OK
------------------------------------------
@@ -0,0 +1,36 @@
================ Step #1 =================
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/test/ConstKt.class
End of files
Compiling files:
src/const.kt
End of files
Exit code: OK
------------------------------------------
================ Step #2 =================
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/test/ConstKt.class
End of files
Compiling files:
src/const.kt
End of files
Marked as dirty by Kotlin:
src/usage.kt
Exit code: ADDITIONAL_PASS_REQUIRED
------------------------------------------
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/test/ConstKt.class
out/production/module/test/Usage.class
End of files
Compiling files:
src/const.kt
src/usage.kt
End of files
Exit code: OK
------------------------------------------
@@ -0,0 +1,24 @@
================ Step #1 =================
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/test/ConstKt.class
End of files
Compiling files:
src/const.kt
End of files
Marked as dirty by Kotlin:
src/usage.kt
Exit code: ADDITIONAL_PASS_REQUIRED
------------------------------------------
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/test/ConstKt.class
out/production/module/test/Usage.class
End of files
Compiling files:
src/const.kt
src/usage.kt
End of files
Exit code: OK
------------------------------------------