@@ -9,6 +9,7 @@ import co.touchlab.skie.util.cache.writeTextIfDifferent
9
9
import co.touchlab.skie.util.directory.SkieBuildDirectory
10
10
import java.nio.file.Path
11
11
import kotlin.io.path.absolute
12
+ import kotlin.io.path.absolutePathString
12
13
import kotlin.io.path.extension
13
14
14
15
class SirFileProvider (
@@ -17,33 +18,33 @@ class SirFileProvider(
17
18
private val skieBuildDirectory : SkieBuildDirectory ,
18
19
) {
19
20
20
- private val irFileByPathCache = mutableMapOf<Path , SirIrFile >()
21
+ private val irFileByPathCache = mutableMapOf<String , SirIrFile >()
21
22
22
- private val writtenSourceFileByPathCache = mutableMapOf<Path , SirSourceFile >()
23
+ private val writtenSourceFileByPathCache = mutableMapOf<String , SirSourceFile >()
23
24
24
- private val generatedSourceFileByPathCache = mutableMapOf<Path , SirSourceFile >()
25
+ private val generatedSourceFileByPathCache = mutableMapOf<String , SirSourceFile >()
25
26
26
27
private val skieNamespace: String
27
28
get() = kirProvider.skieModule.name
28
29
29
30
fun getWrittenSourceFileFromSkieNamespace (name : String ): SirSourceFile {
30
31
val path = relativePath(skieNamespace, name)
31
32
32
- check(path !in generatedSourceFileByPathCache) {
33
+ check(path.asCacheKey !in generatedSourceFileByPathCache) {
33
34
" Generated source file for $path already exists. Combining written and generated source files is not supported."
34
35
}
35
36
36
- return writtenSourceFileByPathCache.getOrPut(path) {
37
+ return writtenSourceFileByPathCache.getOrPut(path.asCacheKey ) {
37
38
SirSourceFile (skieModule, path)
38
39
}
39
40
}
40
41
41
42
fun getGeneratedSourceFile (irFile : SirIrFile ): SirSourceFile {
42
- check(irFile.relativePath !in writtenSourceFileByPathCache) {
43
+ check(irFile.relativePath.asCacheKey !in writtenSourceFileByPathCache) {
43
44
" Written source file for ${irFile.relativePath} already exists. Combining written and generated source files is not supported."
44
45
}
45
46
46
- return generatedSourceFileByPathCache.getOrPut(irFile.relativePath) {
47
+ return generatedSourceFileByPathCache.getOrPut(irFile.relativePath.asCacheKey ) {
47
48
SirSourceFile (irFile.module, irFile.relativePath, irFile)
48
49
}
49
50
}
@@ -52,7 +53,7 @@ class SirFileProvider(
52
53
getIrFile(skieNamespace, name)
53
54
54
55
fun getIrFile (namespace : String , name : String ): SirIrFile =
55
- irFileByPathCache.getOrPut(relativePath(namespace, name)) {
56
+ irFileByPathCache.getOrPut(relativePath(namespace, name).asCacheKey ) {
56
57
SirIrFile (namespace, name, skieModule)
57
58
}
58
59
@@ -84,6 +85,9 @@ class SirFileProvider(
84
85
return SirCompilableFile (skieModule, absolutePath, null )
85
86
}
86
87
88
+ private val Path .asCacheKey: String
89
+ get() = this .normalize().absolutePathString().lowercase()
90
+
87
91
companion object {
88
92
89
93
fun relativePath (namespace : String , name : String ): Path =
0 commit comments