Hi! How to register your own IDE plugin via MetaId...
# arrow-meta
n
Hi! How to register your own IDE plugin via MetaIde? I'm at the stage when Meta IDE plugin successfully resolves, tests ran. (Thanks to
arrow-meta-examples
). But IDE didn't register plugins ><
Some additional info. A minimal example of current config with updated dependencies, everything compiles. https://github.com/koperagen/arrow-meta-examples/tree/register-ide-plugin/hello-world/cli-and-ide-plugin What i see in logs when starting
runIde
https://gist.github.com/koperagen/faf37cf62ba2b310653c4d0d0f0f545c (no Hello world LineMarker)
r
hi @Nikita Klimenko [JB]!. We are at a cross roads with the IDE part of meta because there is still no clear path from Jetbrains whether compiler plugins will see IDE support. If that is the case then users would not need to develop their own IDE parts which is beneficial since Meta does not really want to extend IDEA but provide easy metaprogramming for the Kotlin compiler. Aside from that, for the hello world example I don’t see anything out of the ordinary. Maybe @Imran/Malic can take a look since he worked on that part and see if there is something that needs to be fixed in your repo for the IDE plugin to run.
i
Hi @Nikita Klimenko [JB] sorry for the late response. There is currently no example in the project how to define a set up for Ide plugin’s but it is very similar to the CLI. We define our entry-point:
Copy code
class MyIdeMetaPlugin : MyMetaPlugin(), MetaIde  {
 /** ... **/
}
IdeMetaPlugin
is not supposed to be inherited (as of now), as a means to register ones Ide plugin. That is done through the interface
MetaIde
. If you’re solely focused on IdePlugin’s, this is enough:
Copy code
class MyIdeMetaPlugin : MetaIde {
 /** ... **/
}
That’s why in the logs the Quotes, Type proofs Ide is registered, even though you’ve overwritten
invoke
. Those get automatically registered once the Ide tries to resolve you’re current code 😄
There is an easy fix if you need some members of IdeMetaPlugin, let me know if that is needed
n
Hi @Imran/Malic I've updated setup, now it looks like this
Copy code
@ExperimentalContracts
class MyIdeMetaPlugin : MetaIde {
  @ExperimentalContracts
  override fun intercept(ctx: CompilerContext): List<CliPlugin> =
    emptyList()

  @ExperimentalContracts
  override fun intercept(ctx: IdeContext): List<IdePlugin> =
    listOf(
      helloWorld
    )
}
But still can't make helloWorld work in IDE. I believe it doesn't work because it absents in logs. Is it necessary to declare
MyIdeMetaPlugin
somewhere in plugins.xml? As i understand, no. Just dependency on
<depends>io.arrow-kt.arrow</depends>
. Correct? ^^
i
Sometimes the Ide state is not updated, when runed again. It helps to clean, kill all java processes and gradle demons. In most cases I usually write tests, because those don’t carry the burden to deal with the humongous set up to spin up the UI. Here is one minimal example https://github.com/arrow-kt/arrow-meta/commit/c0fac17d081ee93ecdcb2118a71eae6a22d4ba56 If it’s not working I can take a look at the weekend in your project. Maybe something is missing to be published from our side.
n
I've tried to make a clean build after restarting PC. The situation is the same Unit tests are indeed a huge time saver in this case. In fact, I have written several diagnostics and tests with
Arrow Meta
by now and it was very convenient. My favorite part is that I don't need to write paths to test files, like with native IDE tests, but just pass
String
to function The only thing left is to make plugins work in IDE :c Would really appreciate it if you could take a look
i
💪🏽 Awesome, yes I’ll check that out on Saturday or Sunday. Meanwhile enjoy your weekend 👍🏽
Hi @Nikita Klimenko [JB] sorry for the late response. The main issue here is that in
intellij's
ComponentRegistrar regarding service discovery seems to have a TypeInference issue, when we request 3rd Party Plugins depending on the machinery within
IdeInternalRegistry
. There is a quick fix I can push to Meta. Within you’re project, you’d have to change to the latest SNAPSHOT here to:
Copy code
plugins = ["gradle", "gradle-java", "java", "org.jetbrains.kotlin:${KOTLIN_IDEA_VERSION}", "io.arrow-kt.arrow:1.4.10-SNAPSHOT-1616003761"]
And register your plugin in the PluginXml:
Copy code
<idea-plugin>
    <id>mygroup.myartifact</id>
    <name>My Meta Ide Example</name>
    <vendor email="<mailto:support@yourlibrary.com|support@yourlibrary.com>" url="<http://www.yourlibrary.com>">YourLibrary</vendor>

    <depends>com.intellij.gradle</depends>
    <depends>com.intellij.java</depends>
    <depends>org.jetbrains.kotlin</depends>
    <depends>io.arrow-kt.arrow</depends>

    <extensions defaultExtensionNs="com.intellij">
        <applicationService serviceInterface="arrow.meta.ide.MetaIde" overrides="true" serviceImplementation="io.arrowkt.example.MyIdeMetaPlugin"/>
    </extensions>
</idea-plugin>
In Meta Ide Plugin’s are interpreted as Services. Here you’d substitute the IdePlugin from Upstream Meta to yours. Then you won’t see any logs from Plugin features that you haven’t installed or added.
I will let you know when the fix is published as an artifact with it’s SNAPSHOT number. If you need help, setting things up, you could add me as a Contributor, then I will create a branch for you to set things up
🙌🏽 And big thanks for trying it out.
n
@Imran/Malic Ok, thank you! I will try it out when new snapshot is published