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.js.KotlinJavaScriptMetaFileDecompiler"/>
|
||||||
<psi.classFileDecompiler implementation="org.jetbrains.kotlin.idea.decompiler.builtIns.KotlinBuiltInDecompiler"/>
|
<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.KotlinJvmMetadataVersionIndex"/>
|
||||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinJavaScriptAbiVersionIndex"/>
|
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinJsMetadataVersionIndex"/>
|
||||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinClassFileIndex"/>
|
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinClassFileIndex"/>
|
||||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinJavaScriptMetaFileIndex"/>
|
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinJavaScriptMetaFileIndex"/>
|
||||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinMetadataFileIndex"/>
|
<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 org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object KotlinJavaScriptAbiVersionIndex : KotlinAbiVersionIndexBase<KotlinJavaScriptAbiVersionIndex, JsMetadataVersion>(
|
object KotlinJsMetadataVersionIndex : KotlinMetadataVersionIndexBase<KotlinJsMetadataVersionIndex, JsMetadataVersion>(
|
||||||
KotlinJavaScriptAbiVersionIndex::class.java, ::JsMetadataVersion
|
KotlinJsMetadataVersionIndex::class.java, ::JsMetadataVersion
|
||||||
) {
|
) {
|
||||||
override fun getIndexer() = INDEXER
|
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
|
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.ClassVisitor
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||||
|
|
||||||
object KotlinMetadataVersionIndex : KotlinAbiVersionIndexBase<KotlinMetadataVersionIndex, JvmMetadataVersion>(
|
object KotlinJvmMetadataVersionIndex : KotlinMetadataVersionIndexBase<KotlinJvmMetadataVersionIndex, JvmMetadataVersion>(
|
||||||
KotlinMetadataVersionIndex::class.java, { JvmMetadataVersion(*it) }
|
KotlinJvmMetadataVersionIndex::class.java, ::JvmMetadataVersion
|
||||||
) {
|
) {
|
||||||
override fun getIndexer() = INDEXER
|
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
|
override fun getVersion() = VERSION
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ object KotlinMetadataVersionIndex : KotlinAbiVersionIndexBase<KotlinMetadataVers
|
|||||||
KotlinClassHeader.Kind.MULTIFILE_CLASS
|
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 version: JvmMetadataVersion? = null
|
||||||
var annotationPresent = false
|
var annotationPresent = false
|
||||||
var kind: KotlinClassHeader.Kind? = null
|
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
|
* 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>,
|
private val classOfIndex: Class<T>,
|
||||||
protected val createBinaryVersion: (IntArray) -> V
|
protected val createBinaryVersion: (IntArray) -> V
|
||||||
) : ScalarIndexExtension<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 getKeyDescriptor(): KeyDescriptor<V> = object : KeyDescriptor<V> {
|
||||||
override fun isEqual(val1: V, val2: V): Boolean = val1 == val2
|
override fun isEqual(val1: V, val2: V): Boolean = val1 == val2
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.versions
|
package org.jetbrains.kotlin.idea.versions
|
||||||
|
|
||||||
import com.google.common.collect.Sets
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.module.ModuleManager
|
import com.intellij.openapi.module.ModuleManager
|
||||||
@@ -63,11 +62,11 @@ import java.io.File
|
|||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
fun getLibraryRootsWithAbiIncompatibleKotlinClasses(module: Module): Collection<BinaryVersionedFile<JvmMetadataVersion>> {
|
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>> {
|
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>) {
|
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 allVersions = FileBasedIndex.getInstance().getAllKeys(id, module.project)
|
||||||
val badVersions = allVersions.filterNot(BinaryVersion::isCompatible).toHashSet()
|
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)
|
val fileIndex = ProjectFileIndex.SERVICE.getInstance(module.project)
|
||||||
|
|
||||||
for (version in badVersions) {
|
for (version in badVersions) {
|
||||||
val indexedFiles = FileBasedIndex.getInstance().getContainingFiles(id, version, moduleWithAllDependentLibraries)
|
val indexedFiles = FileBasedIndex.getInstance().getContainingFiles(id, version, moduleWithAllDependentLibraries)
|
||||||
for (indexedFile in indexedFiles) {
|
for (indexedFile in indexedFiles) {
|
||||||
val libraryRoot = fileIndex.getClassRootForFile(indexedFile) ?:
|
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}")
|
"File: ${indexedFile.path}")
|
||||||
badRoots.add(BinaryVersionedFile(getLocalFile(libraryRoot), version, supportedVersion))
|
badRoots.add(BinaryVersionedFile(getLocalFile(libraryRoot), version, supportedVersion))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ class KotlinUpdatePluginComponent : ApplicationComponent {
|
|||||||
|
|
||||||
// Force update indices for files under config directory
|
// Force update indices for files under config directory
|
||||||
val fileBasedIndex = FileBasedIndex.getInstance()
|
val fileBasedIndex = FileBasedIndex.getInstance()
|
||||||
fileBasedIndex.requestRebuild(KotlinMetadataVersionIndex.name)
|
fileBasedIndex.requestRebuild(KotlinJvmMetadataVersionIndex.name)
|
||||||
fileBasedIndex.requestRebuild(KotlinJavaScriptAbiVersionIndex.name)
|
fileBasedIndex.requestRebuild(KotlinJsMetadataVersionIndex.name)
|
||||||
fileBasedIndex.requestRebuild(KotlinClassFileIndex.KEY)
|
fileBasedIndex.requestRebuild(KotlinClassFileIndex.KEY)
|
||||||
fileBasedIndex.requestRebuild(KotlinJavaScriptMetaFileIndex.KEY)
|
fileBasedIndex.requestRebuild(KotlinJavaScriptMetaFileIndex.KEY)
|
||||||
fileBasedIndex.requestRebuild(KotlinMetadataFileIndex.KEY)
|
fileBasedIndex.requestRebuild(KotlinMetadataFileIndex.KEY)
|
||||||
|
|||||||
Reference in New Issue
Block a user