16
16
17
17
package org.jetbrains.kotlin.idea.vfilefinder
18
18
19
- import com.intellij.openapi.diagnostic.Logger
20
19
import com.intellij.util.indexing.*
21
20
import com.intellij.util.io.DataExternalizer
21
+ import com.intellij.util.io.IOUtil
22
22
import com.intellij.util.io.KeyDescriptor
23
23
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
24
24
import org.jetbrains.kotlin.load.kotlin.PackageParts
@@ -27,41 +27,30 @@ import java.io.DataOutput
27
27
28
28
object KotlinModuleMappingIndex : FileBasedIndexExtension<String, PackageParts>() {
29
29
30
- private val classOfIndex = KotlinModuleMappingIndex ::class .java.canonicalName
31
-
32
- val KEY : ID <String , PackageParts > = ID .create(classOfIndex)
30
+ val KEY : ID <String , PackageParts > = ID .create(KotlinModuleMappingIndex ::class .java.canonicalName)
33
31
34
32
private val KEY_DESCRIPTOR = object : KeyDescriptor <String > {
35
- override fun save (output : DataOutput , value : String ) = output .writeUTF(value)
33
+ override fun save (output : DataOutput , value : String ) = IOUtil .writeUTF(output, value)
36
34
37
- override fun read (input : DataInput ) = input .readUTF()
35
+ override fun read (input : DataInput ) = IOUtil .readUTF(input )
38
36
39
37
override fun getHashCode (value : String ) = value.hashCode()
40
38
41
39
override fun isEqual (val1 : String? , val2 : String? ) = val1 == val2
42
40
}
43
41
44
42
private val VALUE_EXTERNALIZER = object : DataExternalizer <PackageParts > {
45
- override fun read (`in `: DataInput ): PackageParts ? {
46
- val packageFqName = `in `.readUTF()
47
- val parts = PackageParts (packageFqName)
48
- val size = `in `.readInt()
49
- (1 .. size).forEach {
50
- parts.parts.add(`in `.readUTF())
51
- }
52
-
53
- return parts
54
- }
43
+ override fun read (input : DataInput ): PackageParts ? =
44
+ PackageParts (IOUtil .readUTF(input)).apply {
45
+ parts.addAll(IOUtil .readStringList(input))
46
+ }
55
47
56
48
override fun save (out : DataOutput , value : PackageParts ? ) {
57
- out .writeUTF(value!! .packageFqName)
58
- out .writeInt(value.parts.size)
59
- value.parts.forEach { out .writeUTF(it) }
49
+ IOUtil .writeUTF(out , value!! .packageFqName)
50
+ IOUtil .writeStringList(out , value.parts)
60
51
}
61
52
}
62
53
63
- private val LOG = Logger .getInstance(classOfIndex)
64
-
65
54
override fun getName () = KEY
66
55
67
56
override fun dependsOnFileContent () = true
@@ -74,7 +63,7 @@ object KotlinModuleMappingIndex : FileBasedIndexExtension<String, PackageParts>(
74
63
return FileBasedIndex .InputFilter { file -> file.extension == ModuleMapping .MAPPING_FILE_EXT }
75
64
}
76
65
77
- override fun getVersion (): Int = 1
66
+ override fun getVersion (): Int = 2
78
67
79
68
override fun getIndexer (): DataIndexer <String , PackageParts , FileContent > {
80
69
return DataIndexer <String , PackageParts , FileContent > { inputData ->
0 commit comments