Platform logo

JetBrains Platform

Plugin and extension development for JetBrains products.


Webinar Recording:  Extending IntelliJ-Based IDEs at Runtime

The fourth episode of the Busy Plugin Developers series is available on JetBrains TV. In this webinar, our guest speaker Dmitry Kandalov demonstrates how to add IDE features at runtime with the help of LivePlugin. If you prefer reading over watching, here’s a quick summary.

Extendending IDEs without implementing a plugin

In some cases, if you need IDE functionality that is specific to your project domain, conventions, or practices, you don’t necessarily need to go through all of the steps of building and releasing a “full” plugin. There are some alternatives out there that can help you more quickly provide these features as a part of your project or IDE configuration. One of these alternatives is adding functionalities at runtime with the help of LivePlugin.

How does LivePlugin work?

LivePlugin adds a new Plugins tool window that lists all available extensions and allows you to manage them. Extensions can be implemented in Kotlin or Groovy and edited directly in the IDE. 

Extensions can use all IntelliJ Platform APIs and the additional LivePlugin API with entry points for common use cases. The plugin compiles and runs code in the same JVM instance as the IDE and has access to all of the IDE’s classes and objects.

Any extensions you’ve created can be loaded automatically for specific projects and shared with other team members.

Why LivePlugin?

The main reason for using LivePlugin as an alternative to plugin development is that it offers a faster and simpler workflow, including:

  • Minimal setup – there’s no need to set up a separate project for plugin development.
  • Faster feedback loop – plugins are executed without restarting the IDE.
  • Simpler API – the smaller API surface area makes extending IDE functionality easier.

So, LivePlugin helps you add smaller features in cases where creating a separate plugin wouldn’t be worth the hassle, such as when you’re adding project-specific scripts and workflows. In a way, it’s like creating IDE macros using a programming language. LivePlugin may also be useful for prototyping plugins and experimenting with the IntelliJ Platform API before creating a real plugin.

LivePlugin implementation details

The general idea is just to load and run Kotlin (or Groovy) classes in the IDE JVM at runtime. The whole workflow can be summarized in three steps:

  1. Dispose of resources from the previous plugin execution.
  2. Compile plugin source code into .class file(s).
  3. Load plugin classes into a newly created classloader and execute the code.

This means that plugin code can use any internal IDE API and observe/change the IDE’s state. Most of the IntelliJ-based IDEs come with a bundled Groovy jar which is used for loading and running live plugins (otherwise, the groovy-all jar will be downloaded). In addition, LivePlugin uses its own version of the Kotlin stdlib and compiler because the version bundled with IDEs changes quite often.

You can find a more detailed explanation of the plugin’s technical implementation in the webinar recording.

About the Speaker

Dmitry Kandalov

Dmitry has been working with JVM languages for more than 15 years and has most recently worked on server-side Kotlin projects. He has given dozens of speeches at dev conferences over the course of his career.

Stay tuned, subscribe to our webinars, and follow JetBrains Platform on Twitter!

image description