com.squareup.anvil.compiler.codegen.reference.AnnotatedReferenceIr.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compiler Show documentation
Show all versions of compiler Show documentation
The core implementation module for Anvil, responsible for hooking into the Kotlin compiler and orchestrating code generation
package com.squareup.anvil.compiler.codegen.reference
import org.jetbrains.kotlin.name.FqName
internal interface AnnotatedReferenceIr {
val annotations: List
fun isAnnotatedWith(fqName: FqName): Boolean =
annotations.any { it.fqName == fqName }
}
internal fun List.find(
annotationName: FqName,
scopeName: FqName? = null,
): List {
return filter {
it.fqName == annotationName && (scopeName == null || it.scopeOrNull?.fqName == scopeName)
}
}
internal fun List.findAll(
vararg annotationNames: FqName,
scopeName: FqName? = null,
) = findAll(annotationNames.toSet(), scopeName)
internal fun List.findAll(
annotationNames: Set,
scopeName: FqName? = null,
): List {
return filter {
it.fqName in annotationNames && (scopeName == null || it.scopeOrNull?.fqName == scopeName)
}
}