Adding extra type information from plugin
已回答
Hi,
I am developing a plugin to the kotlin plugin to add some extra functionality. I want to be able to change the types IntellJ see. For example I would have a list which would define which Java methods' return type or parameters are @Nullable or @NotNull and I want to make IntellJ become aware of it by somehow changing the PSI. I obviously can't change the actual sources, the Java methods would be in libraries. Is this possible at all?
Thanks,
Kristof
请先登录再写评论。
Providing additional annotations can be achieved using builtin feature "External annotations" https://www.jetbrains.com/help/idea/external-annotations.html.
Thank you for your answer, this looks like something I would want to use. Unfortunately though, after having a quick look I encountered the following issues:
- The PSI doesn't seem to recognise the external annotations: if I annotate a Java type with @NotNull, in the Kotlin source code Intellj still thinks it's a platform type even though it also shows the @NotNull annotation when I go to the Java source.
- I couldn't find a way to annotate generic parameters (Intellj doesn't help here but maybe you can specify in the xml somehow?)
- whenever I restart IntellJ it forgets where my annotations were. I am sure I am doing something wrong here though I am not sure what...
Any other ideas how I could do this?
Unfortunately, external annotations are not supported in Kotlin yet.
Feel free to vote for KT-24292 and it would be especially useful if you'd described your use case in the comment.
Thanks!
Ah, thanks, good to know.