https://kotlinlang.org logo
#feed
Title
a

Anastasia Birillo [JB]

09/17/2021, 3:02 PM
Hello everyone! We developed a plugin for the Kotlin compiler that leverages the flows of the standard reflection approach and can find classes, objects or functions by some conditions in compile-time. The current latest version is ready and stable! Two ways of using the plugin are supported: by limited DSL (searching of classes and objects by supertypes and annotations; and searching of functions by signature and annotations) and by extended DSL (searching of classes and objects by custom condition and supertype; and searching of functions by custom condition and signature). Since we use IR generation, the plugin can be used by all platforms (JVM, Nativa and JavaScript). Although currently, we can analyze only kt files. Additionally, the plugin uses a code generation approach in limited DSL to support compile-time reflection in libraries. It means, if you have a library that uses Reflekt and you call something from this library in your project, all Reflekt calls will be in the compile-time. Currently we support 1.5.30, 1.5.21, 1.5.20, 1.5.10, 1.5.0 Kotlin versions. Unfortunately, we do not support incremental compilation yet, but in the next release, we will be! We will be happy if the plugin would be helpful for you! If you are interested in this project and have some ideas for improving the plugin, please don’t hesitate to contact me! To discuss it see #compiler channel
👍 11
🚀 4
😮 2
👀 4
🤘 1
💯 3
K 23
a

altavir

09/17/2021, 5:54 PM
Very interesting. It seems one can do a SPI resolver with this plugin. Am I right?
👍 1
d

Dominaezzz

09/17/2021, 5:55 PM
This came a lot sooner than I expected. 🎉
blob smile happy 1
a

Anastasia Birillo [JB]

09/17/2021, 6:38 PM
@altavir It seems yes, but it's definitely harder than it sounds all the things
k

kenkyee

09/17/2021, 10:35 PM
Can this be used to do something like a lint checker?🙂
a

Anastasia Birillo [JB]

09/18/2021, 9:06 AM
@kenkyee Could you please clarify what you mean perhaps give some example?
k

kenkyee

09/18/2021, 10:53 AM
Nvm... Misunderstood what this did 🙂
d

Dominaezzz

09/18/2021, 11:28 AM
I just realised that this only gives read-only access to the structure. Does this library have anything to with https://github.com/Kotlin/KEEP/issues/149#issuecomment-419470588 ?
a

Anastasia Birillo [JB]

09/20/2021, 1:35 PM
@Dominaezzz Sorry for the long answer! I missed this comment. We discussed the plugin with Roman and others, of course. In the future, it can be a part of it since e.g. currently we have to know all information in compile-time in Reflekt. I mean if you put some annotation to a variable and use it in a Reflekt query, it will not work. But if Kotlin could process some constant propagation or something like this in the compile-time, you will be able to do this automatically. So far, there is definitely no need to transfer the functionality of the plugin to the compiler itself, since the plugin solves a small task that can be used in a small set of applications
👍🏼 1
5 Views