Anastasia Birillo [JB]

    Anastasia Birillo [JB]

    1 year ago
    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
    altavir

    altavir

    1 year ago
    Very interesting. It seems one can do a SPI resolver with this plugin. Am I right?
    Dominaezzz

    Dominaezzz

    1 year ago
    This came a lot sooner than I expected. 🎉
    Anastasia Birillo [JB]

    Anastasia Birillo [JB]

    1 year ago
    @altavir It seems yes, but it's definitely harder than it sounds :all-the-things:
    kenkyee

    kenkyee

    1 year ago
    Can this be used to do something like a lint checker?🙂
    Anastasia Birillo [JB]

    Anastasia Birillo [JB]

    1 year ago
    @kenkyee Could you please clarify what you mean perhaps give some example?
    kenkyee

    kenkyee

    1 year ago
    Nvm... Misunderstood what this did 🙂
    Dominaezzz

    Dominaezzz

    1 year ago
    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 ?
    Anastasia Birillo [JB]

    Anastasia Birillo [JB]

    1 year ago
    @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