Minor. Move BinaryJavaModifierListOwner -> MapBasedJavaAnnotationOwner

This commit is contained in:
Denis Zharkov
2017-05-30 15:43:24 +03:00
parent 2d1e1cb6ed
commit b7ead75947
5 changed files with 17 additions and 20 deletions
@@ -38,7 +38,7 @@ class BinaryJavaClass(
override var access: Int = 0,
override val outerClass: JavaClass?,
classContent: ByteArray? = null
) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, BinaryJavaAnnotationOwner {
) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MapBasedJavaAnnotationOwner {
lateinit var myInternalName: String
override val annotations: MutableCollection<JavaAnnotation> = mutableListOf()
@@ -33,7 +33,7 @@ abstract class BinaryJavaMethodBase(
val valueParameters: List<JavaValueParameter>,
val typeParameters: List<JavaTypeParameter>,
override val name: Name
) : JavaMember, BinaryJavaAnnotationOwner, BinaryJavaModifierListOwner {
) : JavaMember, MapBasedJavaAnnotationOwner, BinaryJavaModifierListOwner {
override val annotationsByFqName by buildLazyValueForMap()
override val annotations: Collection<JavaAnnotation> = mutableListOf()
@@ -30,7 +30,7 @@ class BinaryJavaField(
override val isEnumEntry: Boolean,
override val type: JavaType,
override val initializerValue: Any?
) : JavaField, BinaryJavaAnnotationOwner, BinaryJavaModifierListOwner {
) : JavaField, MapBasedJavaAnnotationOwner, BinaryJavaModifierListOwner {
override val annotations: MutableCollection<JavaAnnotation> = ContainerUtil.newSmartList()
override val annotationsByFqName by buildLazyValueForMap()
@@ -53,7 +53,7 @@ class BinaryJavaValueParameter(
override val name: Name?,
override val type: JavaType,
override val isVararg: Boolean
) : JavaValueParameter, BinaryJavaAnnotationOwner {
) : JavaValueParameter, MapBasedJavaAnnotationOwner {
override val annotations: MutableCollection<JavaAnnotation> = ContainerUtil.newSmartList()
override val annotationsByFqName by buildLazyValueForMap()
}
@@ -19,22 +19,13 @@ package org.jetbrains.kotlin.load.java.structure.impl.classFiles
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.load.java.JavaVisibilities
import org.jetbrains.kotlin.load.java.structure.JavaAnnotation
import org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner
import org.jetbrains.kotlin.load.java.structure.JavaModifierListOwner
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.load.java.structure.MapBasedJavaAnnotationOwner
import org.jetbrains.org.objectweb.asm.Opcodes
internal val ASM_API_VERSION_FOR_CLASS_READING = Opcodes.ASM5
internal interface BinaryJavaAnnotationOwner : JavaAnnotationOwner {
val annotationsByFqName: Map<FqName, JavaAnnotation>
override fun findAnnotation(fqName: FqName) = annotationsByFqName[fqName]
override val isDeprecatedInJavaDoc: Boolean
get() = false
}
internal interface BinaryJavaModifierListOwner : JavaModifierListOwner, BinaryJavaAnnotationOwner {
internal interface BinaryJavaModifierListOwner : JavaModifierListOwner, MapBasedJavaAnnotationOwner {
val access: Int
fun isSet(flag: Int) = access.isSet(flag)
@@ -54,8 +45,4 @@ internal interface BinaryJavaModifierListOwner : JavaModifierListOwner, BinaryJa
override val isDeprecatedInJavaDoc get() = isSet(Opcodes.ACC_DEPRECATED)
}
internal fun JavaAnnotationOwner.buildLazyValueForMap() = lazy {
annotations.filter { it.classId != null }.associateBy({ it.classId!!.asSingleFqName() }, { it })
}
internal fun Int.isSet(flag: Int) = this and flag != 0