mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add stub serialization version to prebuilt stubs version file IDEA-218097
GitOrigin-RevId: 40df5213c56640875d46f4e3f90b5ef203824399
This commit is contained in:
committed by
intellij-monorepo-bot
parent
074a5b0e8a
commit
5e8a568bb7
@@ -10,6 +10,7 @@ import com.intellij.openapi.fileTypes.FileTypeExtension
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.text.StringUtilRt
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.indexing.FileBasedIndexExtension
|
||||
import com.intellij.util.indexing.FileContent
|
||||
import com.intellij.util.indexing.ID
|
||||
import com.intellij.util.io.*
|
||||
@@ -19,6 +20,7 @@ import java.io.DataInput
|
||||
import java.io.DataOutput
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.util.function.UnaryOperator
|
||||
|
||||
const val EP_NAME = "com.intellij.filetype.prebuiltStubsProvider"
|
||||
@@ -108,9 +110,20 @@ abstract class PrebuiltStubsProviderBase : PrebuiltIndexProviderBase<SerializedS
|
||||
}
|
||||
|
||||
override fun openIndexStorage(indexesRoot: File): PersistentHashMap<HashCode, SerializedStubTree>? {
|
||||
val versionInFile = indexesRoot.toPath().resolve("$indexName.version").readText()
|
||||
if (StringUtilRt.parseInt(versionInFile, 0) != stubVersion) {
|
||||
LOG.error("Prebuilt stubs version mismatch: $versionInFile, current version is $stubVersion")
|
||||
val versionFileText = Files.readAllLines(indexesRoot.toPath().resolve("$indexName.version"))
|
||||
if (versionFileText.size != 2) {
|
||||
LOG.error("Invalid version file format: \"$versionFileText\"")
|
||||
return null
|
||||
}
|
||||
val stubSerializationVersion = versionFileText[0]
|
||||
val currentSerializationVersion = StringUtilRt.parseInt(stubSerializationVersion, 0)
|
||||
if (currentSerializationVersion != FileBasedIndexExtension.EXTENSION_POINT_NAME.findExtension(StubUpdatingIndex::class.java)!!.version) {
|
||||
LOG.error("Stub serialization version mismatch: $stubSerializationVersion, current version is $currentSerializationVersion")
|
||||
return null
|
||||
}
|
||||
val prebuiltIndexVersion = versionFileText[1]
|
||||
if (StringUtilRt.parseInt(prebuiltIndexVersion, 0) != stubVersion) {
|
||||
LOG.error("Prebuilt stubs version mismatch: $prebuiltIndexVersion, current version is $stubVersion")
|
||||
return null
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.impl.DebugUtil
|
||||
import com.intellij.psi.stubs.*
|
||||
import com.intellij.util.indexing.FileBasedIndexExtension
|
||||
import com.intellij.util.indexing.FileContentImpl
|
||||
import com.intellij.util.io.PersistentHashMap
|
||||
import junit.framework.TestCase
|
||||
@@ -66,7 +67,11 @@ open class StubsGenerator(private val stubsVersion: String, private val stubsSto
|
||||
}
|
||||
|
||||
fun writeStubsVersionFile(stubsStorageFilePath: String, stubsVersion: String) {
|
||||
FileUtil.writeToFile(File("$stubsStorageFilePath.version"), stubsVersion)
|
||||
val stubSerializationVersion = FileBasedIndexExtension
|
||||
.EXTENSION_POINT_NAME
|
||||
.findExtension(StubUpdatingIndex::class.java)!!
|
||||
.version
|
||||
FileUtil.writeToFile(File("$stubsStorageFilePath.version"), "$stubSerializationVersion\n$stubsVersion")
|
||||
}
|
||||
|
||||
fun mergeStubs(paths: List<String>, stubsFilePath: String, stubsFileName: String, projectPath: String, stubsVersion: String) {
|
||||
|
||||
Reference in New Issue
Block a user