Use JvmMetadataVersion where appropriate instead of bytecode version
This commit is contained in:
+2
-2
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.idea.decompiler.textBuilder.DecompiledText
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.ResolverForDecompiler
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.buildDecompiledText
|
||||
import org.jetbrains.kotlin.idea.decompiler.textBuilder.defaultDecompilerRendererOptions
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
@@ -83,7 +83,7 @@ fun buildDecompiledTextForClassFile(
|
||||
if (!classHeader.metadataVersion.isCompatible()) {
|
||||
return DecompiledText(
|
||||
INCOMPATIBLE_ABI_VERSION_COMMENT
|
||||
.replace(CURRENT_ABI_VERSION_MARKER, JvmBytecodeBinaryVersion.INSTANCE.toString())
|
||||
.replace(CURRENT_ABI_VERSION_MARKER, JvmMetadataVersion.INSTANCE.toString())
|
||||
.replace(FILE_ABI_VERSION_MARKER, classHeader.metadataVersion.toString()),
|
||||
mapOf()
|
||||
)
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class LoggingErrorReporter(private val log: Logger) : ErrorReporter {
|
||||
log.error("Could not infer visibility for $descriptor")
|
||||
}
|
||||
|
||||
override fun reportIncompatibleAbiVersion(classId: ClassId, filePath: String, actualVersion: BinaryVersion) {
|
||||
override fun reportIncompatibleMetadataVersion(classId: ClassId, filePath: String, actualVersion: BinaryVersion) {
|
||||
log.error("Incompatible ABI version for class $classId, actual version: $actualVersion")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,7 +567,7 @@
|
||||
<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.KotlinAbiVersionIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinMetadataVersionIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.versions.KotlinJavaScriptAbiVersionIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinClassFileIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.kotlin.idea.vfilefinder.KotlinJavaScriptMetaFileIndex"/>
|
||||
|
||||
+6
-6
@@ -22,15 +22,15 @@ import com.intellij.util.indexing.FileBasedIndex
|
||||
import com.intellij.util.indexing.FileContent
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.asmDescByFqNameWithoutInnerClasses
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.*
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
|
||||
object KotlinAbiVersionIndex : KotlinAbiVersionIndexBase<KotlinAbiVersionIndex>(
|
||||
KotlinAbiVersionIndex::class.java, { JvmBytecodeBinaryVersion.create(it) }
|
||||
object KotlinMetadataVersionIndex : KotlinAbiVersionIndexBase<KotlinMetadataVersionIndex>(
|
||||
KotlinMetadataVersionIndex::class.java, { JvmMetadataVersion.create(it) }
|
||||
) {
|
||||
override fun getIndexer() = INDEXER
|
||||
|
||||
@@ -38,7 +38,7 @@ object KotlinAbiVersionIndex : KotlinAbiVersionIndexBase<KotlinAbiVersionIndex>(
|
||||
|
||||
override fun getVersion() = VERSION
|
||||
|
||||
private val VERSION = 2
|
||||
private val VERSION = 3
|
||||
|
||||
private val kotlinAnnotationsDesc = setOf(
|
||||
KOTLIN_CLASS,
|
||||
@@ -61,7 +61,7 @@ object KotlinAbiVersionIndex : KotlinAbiVersionIndexBase<KotlinAbiVersionIndex>(
|
||||
return object : AnnotationVisitor(Opcodes.ASM5) {
|
||||
override fun visit(name: String, value: Any) {
|
||||
if (name == VERSION_FIELD_NAME && value is IntArray) {
|
||||
version = JvmBytecodeBinaryVersion.create(value)
|
||||
version = JvmMetadataVersion.create(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ object KotlinAbiVersionIndex : KotlinAbiVersionIndexBase<KotlinAbiVersionIndex>(
|
||||
|
||||
if (annotationPresent && version == null) {
|
||||
// No version at all because the class is too old, or version is set to something weird
|
||||
version = JvmBytecodeBinaryVersion.INVALID_VERSION
|
||||
version = JvmMetadataVersion.INVALID_VERSION
|
||||
}
|
||||
|
||||
if (version != null) mapOf(version!! to null) else mapOf()
|
||||
@@ -69,7 +69,7 @@ public class KotlinRuntimeLibraryUtil {
|
||||
@NotNull
|
||||
public static Collection<VirtualFile> getLibraryRootsWithAbiIncompatibleKotlinClasses(@NotNull Project project) {
|
||||
return getLibraryRootsWithAbiIncompatibleVersion(
|
||||
project, KotlinAbiVersionIndex.INSTANCE,
|
||||
project, KotlinMetadataVersionIndex.INSTANCE,
|
||||
new Function1<Module, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(@Nullable Module module) {
|
||||
|
||||
@@ -62,7 +62,7 @@ class KotlinUpdatePluginComponent : ApplicationComponent {
|
||||
|
||||
// Force update indices for files under config directory
|
||||
val fileBasedIndex = FileBasedIndex.getInstance()
|
||||
fileBasedIndex.requestRebuild(KotlinAbiVersionIndex.name)
|
||||
fileBasedIndex.requestRebuild(KotlinMetadataVersionIndex.name)
|
||||
fileBasedIndex.requestRebuild(KotlinJavaScriptAbiVersionIndex.name)
|
||||
fileBasedIndex.requestRebuild(KotlinClassFileIndex.KEY)
|
||||
fileBasedIndex.requestRebuild(KotlinJavaScriptMetaFileIndex.KEY)
|
||||
|
||||
Reference in New Issue
Block a user