All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.squareup.anvil.compiler.codegen.reference.AnnotatedReferenceIr.kt Maven / Gradle / Ivy

Go to download

The core implementation module for Anvil, responsible for hooking into the Kotlin compiler and orchestrating code generation

There is a newer version: 0.4.0
Show newest version
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)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy