-
Notifications
You must be signed in to change notification settings - Fork 86
Description
In a sample project, the @Style is use to Field in Companion object. The @Style Annotation is targeted to field and function @Target(FIELD, FUNCTION)
So I tried that annotation to function like this in SectionView.kt
companion object { @Style fun styleFunctionTest() = sectionViewStyle { backgroundRes(android.R.color.transparent) paddingBottomRes(R.dimen.space4) paddingLeftRes(R.dimen.space4) paddingRightRes(R.dimen.space4) paddingTopRes(R.dimen.space4) titleStyle(defaultTitleStyle(Color.BLUE)) contentStyle(DEFAULT_CONTENT_STYLE) thumbnailStyle(IMAGE_VIEW_STYLE) dividerColor(Color.parseColor("#DDDDDD")) dividerHeightDp(1) } }
But I can't run this code, getting compile error
Methods annotated with @Style must be static and can't be private or protected. [element=styleFunctionTest() JavacMethodElement in com.changgyu.parissample.SectionView.Companion]
That is so weird, because the function is static and not private or protected.
Also I tried to understand that error and found the processor code line in StyleStaticMethodInfoExtractor.kt
`
override fun elementToModel(element: XMethodElement): StyleStaticMethodInfo? {
// TODO Get Javadoc from field/method and add it to the generated methods
if (!element.isStatic() || element.isPrivate() || element.isProtected()) {
parisProcessor.logError(element) {
"Methods annotated with @Style must be static and can't be private or protected."
}
return null
}
......
`