Rewrite KotlinClassHeader to Kotlin

This commit is contained in:
Alexander Udalov
2014-03-07 03:39:55 +04:00
parent 39cd3b1e13
commit 4937812414
7 changed files with 52 additions and 89 deletions
@@ -38,7 +38,7 @@ public fun buildDecompiledText(
val classFqName = kotlinClass.getClassName().getFqNameForClassNameWithoutDollars()
val classFileHeader = kotlinClass.getClassHeader()
assert(classFileHeader != null) { "Decompiled data factory shouldn't be called on an unsupported file: " + classFile }
val kind = classFileHeader!!.getKind()
val kind = classFileHeader!!.kind
val packageFqName = classFqName.parent()
return if (kind == KotlinClassHeader.Kind.PACKAGE_FACADE) {
@@ -31,7 +31,7 @@ public fun isKotlinCompiledFile(file: VirtualFile): Boolean {
return false
}
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file).getClassHeader()
return header != null && header.getSyntheticClassKind() != KotlinSyntheticClass.Kind.TRAIT_IMPL
return header != null && header.syntheticClassKind != KotlinSyntheticClass.Kind.TRAIT_IMPL
}
public fun isKotlinCompiledFileWithIncompatibleAbiVersion(file: VirtualFile): Boolean {
@@ -39,7 +39,7 @@ public fun isKotlinCompiledFileWithIncompatibleAbiVersion(file: VirtualFile): Bo
return false
}
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file).getClassHeader()
return header?.getKind() == KotlinClassHeader.Kind.INCOMPATIBLE_ABI_VERSION
return header?.kind == KotlinClassHeader.Kind.INCOMPATIBLE_ABI_VERSION
}
public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean {
@@ -50,5 +50,5 @@ public fun isKotlinInternalCompiledFile(file: VirtualFile): Boolean {
return true
}
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file).getClassHeader()
return header?.getKind() == KotlinClassHeader.Kind.SYNTHETIC_CLASS
return header?.kind == KotlinClassHeader.Kind.SYNTHETIC_CLASS
}
@@ -35,7 +35,6 @@ import org.jetbrains.jet.lang.resolve.kotlin.DeserializedResolverUtils
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPackageMemberScope
import org.jetbrains.jet.lang.resolve.kotlin.AnnotationDescriptorDeserializer
import org.jetbrains.jet.lang.resolve.java.resolver.ErrorReporter
import org.jetbrains.jet.lang.types.ErrorUtils.getErrorModule
import org.jetbrains.jet.lang.types.error.MissingDependencyErrorClassDescriptor
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils
import com.intellij.openapi.diagnostic.Logger
@@ -57,7 +56,7 @@ public class DeserializerForDecompiler(val packageDirectory: VirtualFile, val di
assert(packageFqName == directoryPackageFqName, "Was called for $packageFqName but only $directoryPackageFqName is expected.")
val packageClassFqName = PackageClassUtils.getPackageClassFqName(packageFqName)
val binaryClassForPackageClass = localClassFinder.findKotlinClass(packageClassFqName)
val annotationData = binaryClassForPackageClass?.getClassHeader()?.getAnnotationData()
val annotationData = binaryClassForPackageClass?.getClassHeader()?.annotationData
if (annotationData == null) {
LOG.error("Could not read annotation data for $packageFqName from ${binaryClassForPackageClass?.getClassName()}")
return Collections.emptyList()
@@ -145,7 +144,7 @@ public class DeserializerForDecompiler(val packageDirectory: VirtualFile, val di
}
private fun deserializeBinaryClass(kotlinClass: KotlinJvmBinaryClass): ClassDescriptor {
val data = kotlinClass.getClassHeader()?.getAnnotationData()
val data = kotlinClass.getClassHeader()?.annotationData
if (data == null) {
LOG.error("Annotation data missing for ${kotlinClass.getClassName()}")
}
@@ -24,18 +24,13 @@ import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.jet.lang.resolve.java.JvmAbi
import com.intellij.psi.PsiManager
import junit.framework.Assert
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils
import com.intellij.psi.ClassFileViewProvider
import com.intellij.psi.impl.compiled.ClsFileImpl
import com.intellij.psi.PsiCompiledFile
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiJavaFile
import org.jetbrains.jet.lang.resolve.kotlin.header.KotlinClassHeader
import org.jetbrains.jet.storage.LockBasedStorageManager
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass.Kind.*
import org.jetbrains.jet.lang.resolve.kotlin.KotlinBinaryClassCache
import com.intellij.openapi.fileTypes.StdFileTypes
public class InternalCompiledClassesTest : JetLightCodeInsightFixtureTestCase() {
@@ -85,7 +80,7 @@ public class InternalCompiledClassesTest : JetLightCodeInsightFixtureTestCase()
private fun isSyntheticClassOfKind(kind: KotlinSyntheticClass.Kind) : VirtualFile.() -> Boolean = {
val header = KotlinBinaryClassCache.getKotlinBinaryClass(this).getClassHeader()
header?.getSyntheticClassKind() == kind
header?.syntheticClassKind == kind
}
private fun doTestNoPsiFilesAreBuiltForSyntheticClass(kind: KotlinSyntheticClass.Kind) =