Clearing constants data when removing file.
Original commit: fc7dceba5a
This commit is contained in:
@@ -74,13 +74,14 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
|
|||||||
if (header.syntheticClassKind == JvmAnnotationNames.KotlinSyntheticClass.Kind.PACKAGE_PART) {
|
if (header.syntheticClassKind == JvmAnnotationNames.KotlinSyntheticClass.Kind.PACKAGE_PART) {
|
||||||
assert(sourceFiles.size == 1) { "Package part from several source files: $sourceFiles" }
|
assert(sourceFiles.size == 1) { "Package part from several source files: $sourceFiles" }
|
||||||
packagePartMap.putPackagePartSourceData(moduleId, sourceFiles.first(), className)
|
packagePartMap.putPackagePartSourceData(moduleId, sourceFiles.first(), className)
|
||||||
return constantsMap.process(className, fileBytes)
|
return constantsMap.process(moduleId, sourceFiles.first(), fileBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun clearCacheForRemovedFile(moduleId: String, sourceFile: File) {
|
public fun clearCacheForRemovedFile(moduleId: String, sourceFile: File) {
|
||||||
|
constantsMap.remove(moduleId, sourceFile)
|
||||||
packagePartMap.remove(moduleId, sourceFile)
|
packagePartMap.remove(moduleId, sourceFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +136,10 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
|
|||||||
ConstantsMapExternalizer
|
ConstantsMapExternalizer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun getKey(moduleId: String, sourceFile: File): String {
|
||||||
|
return moduleId + File.pathSeparator + sourceFile.getAbsolutePath()
|
||||||
|
}
|
||||||
|
|
||||||
private fun getConstantsMap(bytes: ByteArray): Map<String, Any> {
|
private fun getConstantsMap(bytes: ByteArray): Map<String, Any> {
|
||||||
val result = HashMap<String, Any>()
|
val result = HashMap<String, Any>()
|
||||||
|
|
||||||
@@ -150,12 +155,12 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun process(packagePartClass: JvmClassName, bytes: ByteArray): Boolean {
|
public fun process(moduleId: String, file: File, bytes: ByteArray): Boolean {
|
||||||
return put(packagePartClass, getConstantsMap(bytes))
|
return put(moduleId, file, getConstantsMap(bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun put(packagePartClass: JvmClassName, constantsMap: Map<String, Any>): Boolean {
|
private fun put(moduleId: String, file: File, constantsMap: Map<String, Any>): Boolean {
|
||||||
val key = packagePartClass.getInternalName()
|
val key = getKey(moduleId, file)
|
||||||
|
|
||||||
val oldMap = map[key]
|
val oldMap = map[key]
|
||||||
if (oldMap == constantsMap) {
|
if (oldMap == constantsMap) {
|
||||||
@@ -165,6 +170,10 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun remove(moduleId: String, file: File) {
|
||||||
|
map.remove(getKey(moduleId, file))
|
||||||
|
}
|
||||||
|
|
||||||
public fun close() {
|
public fun close() {
|
||||||
map.close()
|
map.close()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user