Minor FilteredAnnotations moved out of Java-specific code
This commit is contained in:
committed by
Denis Zharkov
parent
31f4ff749c
commit
eaae88133c
-24
@@ -44,29 +44,5 @@ class LazyJavaAnnotations(
|
||||
override fun isEmpty() = !iterator().hasNext()
|
||||
}
|
||||
|
||||
class FilteredAnnotations(
|
||||
private val delegate: Annotations,
|
||||
private val fqNameFilter: (FqName) -> Boolean
|
||||
) : Annotations {
|
||||
override fun findAnnotation(fqName: FqName) =
|
||||
if (fqNameFilter(fqName)) delegate.findAnnotation(fqName)
|
||||
else null
|
||||
|
||||
override fun findExternalAnnotation(fqName: FqName) =
|
||||
if (fqNameFilter(fqName)) delegate.findExternalAnnotation(fqName)
|
||||
else null
|
||||
|
||||
override fun iterator() = delegate.asSequence()
|
||||
.filter { annotation ->
|
||||
val descriptor = annotation.getType().getConstructor().getDeclarationDescriptor()
|
||||
descriptor != null && DescriptorUtils.getFqName(descriptor).let { fqName ->
|
||||
fqName.isSafe() && fqNameFilter(fqName.toSafe())
|
||||
}
|
||||
}
|
||||
.iterator()
|
||||
|
||||
override fun isEmpty() = !iterator().hasNext()
|
||||
}
|
||||
|
||||
fun LazyJavaResolverContext.resolveAnnotations(annotationsOwner: JavaAnnotationOwner): Annotations
|
||||
= LazyJavaAnnotations(this, annotationsOwner)
|
||||
|
||||
+1
-1
@@ -20,10 +20,10 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.*
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.FilteredAnnotations
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.lazy.TypeParameterResolver
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND
|
||||
|
||||
Reference in New Issue
Block a user