Introduce BinaryVersion.isCompatible()
To decrease the chance to mix up the receiver and the first argument when checking version compatibility
This commit is contained in:
+2
-2
@@ -53,8 +53,8 @@ fun isKotlinJvmCompiledFile(file: VirtualFile): Boolean {
|
||||
fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean {
|
||||
if (!isKotlinJvmCompiledFile(file)) return false
|
||||
|
||||
val header = IDEKotlinBinaryClassCache.getKotlinBinaryClassHeaderData(file)?.classHeader
|
||||
return header != null && header.isCompatibleAbiVersion
|
||||
val kotlinClass = IDEKotlinBinaryClassCache.getKotlinBinaryClassHeaderData(file)
|
||||
return kotlinClass != null && kotlinClass.classHeader.version.isCompatible()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -86,7 +86,7 @@ fun buildDecompiledTextForClassFile(
|
||||
val packageFqName = classId.packageFqName
|
||||
|
||||
return when {
|
||||
!classHeader.isCompatibleAbiVersion -> {
|
||||
!classHeader.version.isCompatible() -> {
|
||||
DecompiledText(
|
||||
INCOMPATIBLE_ABI_VERSION_COMMENT
|
||||
.replace(CURRENT_ABI_VERSION_MARKER, JvmBytecodeBinaryVersion.INSTANCE.toString())
|
||||
@@ -103,6 +103,6 @@ fun buildDecompiledTextForClassFile(
|
||||
buildDecompiledText(packageFqName, partMembers, decompilerRendererForClassFiles)
|
||||
}
|
||||
else ->
|
||||
throw UnsupportedOperationException("Unknown header kind: ${classHeader.kind} ${classHeader.isCompatibleAbiVersion}")
|
||||
throw UnsupportedOperationException("Unknown header kind: ${classHeader.kind} ${classHeader.version.isCompatible()}")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ open class KotlinClsStubBuilder : ClsStubBuilder() {
|
||||
val header = kotlinClassHeaderInfo.classHeader
|
||||
val classId = kotlinClassHeaderInfo.classId
|
||||
val packageFqName = classId.packageFqName
|
||||
if (!header.isCompatibleAbiVersion) {
|
||||
if (!header.version.isCompatible()) {
|
||||
return createIncompatibleAbiVersionFileStub()
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ object KotlinClassFileIndex : KotlinFileIndexBase<KotlinClassFileIndex>(KotlinCl
|
||||
private val VERSION = 2
|
||||
|
||||
private val INDEXER = indexer() { fileContent ->
|
||||
val kotlinClassHeaderInfo = IDEKotlinBinaryClassCache.getKotlinBinaryClassHeaderData(fileContent.file, fileContent.content)
|
||||
if (kotlinClassHeaderInfo != null && kotlinClassHeaderInfo.classHeader.isCompatibleAbiVersion) kotlinClassHeaderInfo.classId.asSingleFqName() else null
|
||||
val headerInfo = IDEKotlinBinaryClassCache.getKotlinBinaryClassHeaderData(fileContent.file, fileContent.content)
|
||||
if (headerInfo != null && headerInfo.classHeader.version.isCompatible()) headerInfo.classId.asSingleFqName() else null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -46,7 +49,6 @@ import org.jetbrains.kotlin.idea.framework.JSLibraryStdPresentationProvider;
|
||||
import org.jetbrains.kotlin.idea.framework.JavaRuntimePresentationProvider;
|
||||
import org.jetbrains.kotlin.idea.framework.LibraryPresentationProviderUtil;
|
||||
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil;
|
||||
import org.jetbrains.kotlin.load.java.AbiVersionUtil;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion;
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils;
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths;
|
||||
@@ -77,7 +79,7 @@ public class KotlinRuntimeLibraryUtil {
|
||||
new Function1<BinaryVersion, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(@NotNull BinaryVersion version) {
|
||||
return !AbiVersionUtil.isAbiVersionCompatible(version);
|
||||
return !version.isCompatible();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user