Can I compose annotations somehow? I have these t...
# announcements
u
Can I compose annotations somehow? I have these two anntations everywhere
Copy code
@Provides
@JvmStatic
fun widgetUpdater() ..
Can I turn it somehow to this? where
@ProvidesAndJvmStatic
would reference then the daggers
@Provide
and kotlins
@JvmStatic
inside?
Copy code
@ProvidesAndJvmStatic
fun widgetUpdater() ..
🚫 2
c
Many people have asked for this, as far as I know it's not possible yet
u
Shame
b
Spring allows this via advanced annotation scanning implementation. You could just as easily do the same and just "flatten" composite annotations via a compiler plugin or annotation processor (kapt)
u
you mean as a dagger feature? or my little processor which is then fed to dagger?
b
Second option. Basically annotation processor that detects all annotations marked with @CompositeMarker and then all objects marked with those. e.g:
Copy code
@CompositeMarker
@AnnotationA
@AnnotationB
annotation class CompositeAB
Then just flattens all those annotations on top of the object
The output is then passed in to the rest of the compiler chain
u
Hm, annot processor can change sources? I thought only compiler plugin could do that; and annotation processor only generates new ones
b
Yeah, you need compiler plugin. My bad.