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

tracer.util.getAnnotatedSymbols.kt Maven / Gradle / Ivy

package tracer.util

import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration
import java.util.concurrent.ConcurrentHashMap

@PublishedApi
internal val annotatedSymbolsCache: Any = ConcurrentHashMap>().alsoRegister()

/**
 * Returns [A]s annotated with [T]. These symbols are cached and cleared every round.
 */
@Suppress("UNCHECKED_CAST")
public inline fun  Resolver.getAnnotatedSymbols(): List =
    (annotatedSymbolsCache as MutableMap>)
        .getOrPut(T::class to A::class) {
            getSymbolsWithAnnotation(T::class.qualifiedName!!)
            .filterIsInstance()
            // todo: remove this line after the authoritative fix.
            .distinct()
            .toList()
        } as List

/**
 * Returns [KSClassDeclaration]s annotated with [T], which is cached and cleared every round.
 */
public inline fun  Resolver.getAnnotatedKlasses(): List =
    getAnnotatedSymbols()




© 2015 - 2025 Weber Informatics LLC | Privacy Policy