[IC] Refactor IC maps to reuse code and ensure consistency

The key changes include:
  - Top interface: `PersistentStorage`
  - Implementation:
      + `LazyStorage`
      + `InMemoryStorage`
  - Extended functionality:
      + `BasicMap`
      + `PersistentStorageAdapter`

 The remaining changes are small cleanups to adapt to the above key
 changes.

 Test: Existing tests (refactoring change)
 Bug: N/A (code cleanup)
This commit is contained in:
Hung Nguyen
2023-08-25 20:12:52 +01:00
committed by Space Cloud
parent e8630fd63f
commit 4e89dcf031
26 changed files with 730 additions and 581 deletions
@@ -6,14 +6,13 @@
package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.build.report.DoNothingBuildReporter
import org.jetbrains.kotlin.incremental.storage.InMemoryStorageWrapper
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.jetbrains.kotlin.incremental.storage.InMemoryStorageInterface
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir
import java.io.Closeable
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
@@ -27,23 +26,21 @@ private class CacheMock(private val throwsException: Boolean = false) : Closeabl
}
}
private class InMemoryStorageWrapperMock : InMemoryStorageWrapper<Any, Any> {
private class InMemoryStorageWrapperMock : InMemoryStorageInterface<Any, Any> {
var reset = false
override fun resetInMemoryChanges() {
override fun applyChanges() {}
override fun clearChanges() {
reset = true
}
override val keys: Collection<Any> = emptyList()
override val storageFile = File("")
override fun clean() {}
override fun flush(memoryCachesOnly: Boolean) {}
override val keys: Set<Any> = emptySet()
override fun close() {}
override fun append(key: Any, value: Any) {}
override fun remove(key: Any) {}
override fun set(key: Any, value: Any) {}