I am trying to find all the classes that have been annotated with the "Annotated" class, which I create below as a Scala StaticAnnotation class.
import scala.reflect.runtime.universe._
sealed trait Foo {}
class Annotated() extends scala.annotation.StaticAnnotation
@Annotated() case class AnnotatedFooCase() extends Foo
case class NotAnnotatedFooCase() extends Foo
val annotatedClasses = typeTag[Annotated].tpe.typeSymbol.owner.typeSignature.
decls.filter(_.isPublic).filter(_.isClass).map(_.asClass).filter(_.isCaseClass)
I feel like this code should be working, but checking it out in a worksheet, I see this list is the result
annotatedClasses: Iterable[reflect.runtime.universe.ClassSymbol] = List(class AnnotatedFooCase, class NotAnnotatedFooCase)
I want a list that only includes the correctly annotated classes.
Aucun commentaire:
Enregistrer un commentaire