Rename metadata version index and its subclasses
This commit is contained in:
@@ -671,8 +671,8 @@
|
||||
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.idea.decompiler.js.KotlinJavaScriptMetaFileDecompiler"/>
|
||||
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.idea.decompiler.builtIns.KotlinBuiltInDecompiler"/>
|
||||
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinMetadataVersionIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinJavaScriptAbiVersionIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinJvmMetadataVersionIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinJsMetadataVersionIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinClassFileIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinJavaScriptMetaFileIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinMetadataFileIndex"/>
|
||||
|
||||
+3
-3
@@ -26,12 +26,12 @@ import org.jetbrains.kotlin.utils.KotlinJavascriptMetadata
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
|
||||
import java.util.*
|
||||
|
||||
object KotlinJavaScriptAbiVersionIndex : KotlinAbiVersionIndexBase<KotlinJavaScriptAbiVersionIndex, JsMetadataVersion>(
|
||||
KotlinJavaScriptAbiVersionIndex::class.java, ::JsMetadataVersion
|
||||
object KotlinJsMetadataVersionIndex : KotlinMetadataVersionIndexBase<KotlinJsMetadataVersionIndex, JsMetadataVersion>(
|
||||
KotlinJsMetadataVersionIndex::class.java, ::JsMetadataVersion
|
||||
) {
|
||||
override fun getIndexer() = INDEXER
|
||||
|
||||
override fun getInputFilter() = FileBasedIndex.InputFilter() { file -> JavaScript.EXTENSION == file.extension }
|
||||
override fun getInputFilter() = FileBasedIndex.InputFilter { file -> JavaScript.EXTENSION == file.extension }
|
||||
|
||||
override fun getVersion() = VERSION
|
||||
|
||||
+4
-4
@@ -28,12 +28,12 @@ import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
|
||||
object KotlinMetadataVersionIndex : KotlinAbiVersionIndexBase<KotlinMetadataVersionIndex, JvmMetadataVersion>(
|
||||
KotlinMetadataVersionIndex::class.java, { JvmMetadataVersion(*it) }
|
||||
object KotlinJvmMetadataVersionIndex : KotlinMetadataVersionIndexBase<KotlinJvmMetadataVersionIndex, JvmMetadataVersion>(
|
||||
KotlinJvmMetadataVersionIndex::class.java, ::JvmMetadataVersion
|
||||
) {
|
||||
override fun getIndexer() = INDEXER
|
||||
|
||||
override fun getInputFilter() = FileBasedIndex.InputFilter() { file -> file.fileType == StdFileTypes.CLASS }
|
||||
override fun getInputFilter() = FileBasedIndex.InputFilter { file -> file.fileType == StdFileTypes.CLASS }
|
||||
|
||||
override fun getVersion() = VERSION
|
||||
|
||||
@@ -45,7 +45,7 @@ object KotlinMetadataVersionIndex : KotlinAbiVersionIndexBase<KotlinMetadataVers
|
||||
KotlinClassHeader.Kind.MULTIFILE_CLASS
|
||||
)
|
||||
|
||||
private val INDEXER = DataIndexer<JvmMetadataVersion, Void, FileContent>() { inputData: FileContent ->
|
||||
private val INDEXER = DataIndexer<JvmMetadataVersion, Void, FileContent> { inputData: FileContent ->
|
||||
var version: JvmMetadataVersion? = null
|
||||
var annotationPresent = false
|
||||
var kind: KotlinClassHeader.Kind? = null
|
||||
+2
-2
@@ -29,12 +29,12 @@ import java.io.DataOutput
|
||||
/**
|
||||
* Important! This is not a stub-based index. And it has its own version
|
||||
*/
|
||||
abstract class KotlinAbiVersionIndexBase<T, V : BinaryVersion>(
|
||||
abstract class KotlinMetadataVersionIndexBase<T, V : BinaryVersion>(
|
||||
private val classOfIndex: Class<T>,
|
||||
protected val createBinaryVersion: (IntArray) -> V
|
||||
) : ScalarIndexExtension<V>() {
|
||||
|
||||
override fun getName() = ID.create<V, Void>(classOfIndex.canonicalName)
|
||||
override fun getName(): ID<V, Void> = ID.create<V, Void>(classOfIndex.canonicalName)
|
||||
|
||||
override fun getKeyDescriptor(): KeyDescriptor<V> = object : KeyDescriptor<V> {
|
||||
override fun isEqual(val1: V, val2: V): Boolean = val1 == val2
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.versions
|
||||
|
||||
import com.google.common.collect.Sets
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
@@ -63,11 +62,11 @@ import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
fun getLibraryRootsWithAbiIncompatibleKotlinClasses(module: Module): Collection<BinaryVersionedFile<JvmMetadataVersion>> {
|
||||
return getLibraryRootsWithAbiIncompatibleVersion(module, JvmMetadataVersion.INSTANCE, KotlinMetadataVersionIndex)
|
||||
return getLibraryRootsWithAbiIncompatibleVersion(module, JvmMetadataVersion.INSTANCE, KotlinJvmMetadataVersionIndex)
|
||||
}
|
||||
|
||||
fun getLibraryRootsWithAbiIncompatibleForKotlinJs(module: Module): Collection<BinaryVersionedFile<JsMetadataVersion>> {
|
||||
return getLibraryRootsWithAbiIncompatibleVersion(module, JsMetadataVersion.INSTANCE, KotlinJavaScriptAbiVersionIndex)
|
||||
return getLibraryRootsWithAbiIncompatibleVersion(module, JsMetadataVersion.INSTANCE, KotlinJsMetadataVersionIndex)
|
||||
}
|
||||
|
||||
fun updateLibraries(project: Project, libraries: Collection<Library>) {
|
||||
@@ -259,14 +258,14 @@ private fun <T : BinaryVersion> getLibraryRootsWithAbiIncompatibleVersion(
|
||||
|
||||
val allVersions = FileBasedIndex.getInstance().getAllKeys(id, module.project)
|
||||
val badVersions = allVersions.filterNot(BinaryVersion::isCompatible).toHashSet()
|
||||
val badRoots = Sets.newHashSet<BinaryVersionedFile<T>>()
|
||||
val badRoots = hashSetOf<BinaryVersionedFile<T>>()
|
||||
val fileIndex = ProjectFileIndex.SERVICE.getInstance(module.project)
|
||||
|
||||
for (version in badVersions) {
|
||||
val indexedFiles = FileBasedIndex.getInstance().getContainingFiles(id, version, moduleWithAllDependentLibraries)
|
||||
for (indexedFile in indexedFiles) {
|
||||
val libraryRoot = fileIndex.getClassRootForFile(indexedFile) ?:
|
||||
error("Only library roots were requested, and only class files should be indexed with KotlinAbiVersionIndex key. " +
|
||||
error("Only library roots were requested, and only class files should be indexed with the $id key. " +
|
||||
"File: ${indexedFile.path}")
|
||||
badRoots.add(BinaryVersionedFile(getLocalFile(libraryRoot), version, supportedVersion))
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ class KotlinUpdatePluginComponent : ApplicationComponent {
|
||||
|
||||
// Force update indices for files under config directory
|
||||
val fileBasedIndex = FileBasedIndex.getInstance()
|
||||
fileBasedIndex.requestRebuild(KotlinMetadataVersionIndex.name)
|
||||
fileBasedIndex.requestRebuild(KotlinJavaScriptAbiVersionIndex.name)
|
||||
fileBasedIndex.requestRebuild(KotlinJvmMetadataVersionIndex.name)
|
||||
fileBasedIndex.requestRebuild(KotlinJsMetadataVersionIndex.name)
|
||||
fileBasedIndex.requestRebuild(KotlinClassFileIndex.KEY)
|
||||
fileBasedIndex.requestRebuild(KotlinJavaScriptMetaFileIndex.KEY)
|
||||
fileBasedIndex.requestRebuild(KotlinMetadataFileIndex.KEY)
|
||||
|
||||
Reference in New Issue
Block a user