Resource annotations and @IntDef and @StringDef

Are there any plans to introduce support for integer annotations for resources in Android, such as @StringRes, @ColorRes, @LayoutRes, along with the lint checks around them.

Also, it would be nice if we could get support for @IntDef and @StringDef. I’m sure that every Android programmer has learned to appreciate them.

Cheers.

2 Likes

I also hoping that they would be supported with the changes that came in 1.0.2 regarding Android annotations. I suppose this is coming later? Or are the support annotations not yet on the list?

Kotlin 1.0.2 includes Android Lint diagnostics, so @ColorRes, @LayoutRes and other annotations are supported now.
Note that Lint diagnostics are in beta, so please create an issue if something does not work as expected.

How does one enable this functionality, because I could not see it for my code.

With either 1.1 or 1.1.1 I started getting bogus lint underlines on @IntegerRes

class IntRangeAdapter(val context: Context,
                      @IntegerRes var resource: Int,
                      @IntegerRes var dropDownResource: Int,
                      minInclusive_: Int,
                      maxInclusive_: Int)

both the @IntegerRes are linted. Is this because the IDE just started considering them in 1.1? I think the linting is wrong…
The lint error is “This annotation does not apply for type void”