Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Style doesn't work at Function #163

Open
changgyu-brandi opened this issue Dec 2, 2021 · 0 comments
Open

@Style doesn't work at Function #163

changgyu-brandi opened this issue Dec 2, 2021 · 0 comments

Comments

@changgyu-brandi
Copy link

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
    }

......
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant