r

    radekm

    1 year ago
    Hi, I have written a simple compiler plugin with Arrow Meta. My plugin replaces every data class with
    Bar
    data class. My program builds and runs successfully but IntelliJ thinks it is wrong:
    I have installed Arrow Idea plugin but it did not help
    My
    build.gradle.kts
    for the project where I use the plugin
    plugins {
        kotlin("jvm")
    }
    
    tasks.withType<KotlinCompile>() {
        kotlinOptions.jvmTarget = "11"
        kotlinOptions.freeCompilerArgs = listOf("-Xplugin=${rootDir}/my-plugin/build/libs/my-plugin.jar")
    }
    
    val arrow_version = "0.11.0"
    dependencies {
        compileOnly("io.arrow-kt:arrow-annotations:0.11.0")
    }
    
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        this.dependsOn(":my-plugin:assemble")
    }
    What can I do to fix it?
    raulraja

    raulraja

    1 year ago
    Hi @radekm, nothing really since that kind of transformation will soon be unsupported for the very reason you showed there. The issue here is that in place tree transformations require generation of synthetic descriptors and an IDE plugin but there is no solution for code locations or coordination with the actual document in the IDE. For that reason we are gonna drop support for Transform.replace and support only Transform.newSources until FIR is released and there is a solution for this kind of transformation that does not require users to install an IDE plugin.
    r

    radekm

    1 year ago
    Ok, makes sense. Thanks. I think I will be able to circumvent it by calling the original class with some crazy name like
    class `temp Foo`()
    and then leaving it in AST
    Vladimir Mutafov

    Vladimir Mutafov

    1 year ago
    too bad, although many things could be achieved with generating new sources, sometimes it is really not optimal
    I have a use case where I would either replace in place or generate loooots of synthetic methods
    Would FIR actually bridge the compiler and intelliJ? Sorry if it’s a stupid question, I’m not much into intelliJ plugins and code analysis there