Kotlin Notebook Integration
The Kotlin Notebook IntelliJ Platform integration enables interactive development and experimentation with IntelliJ Platform APIs directly within a notebook environment. This integration allows developers to run IntelliJ Platform code within the active IDE runtime, removing traditional barriers associated with plugin project setup, compilation, and deployment.
Like Jupyter Notebooks, Kotlin Notebook provides an interactive platform for prototyping, testing, and exploring IntelliJ Platform functionality through executable code cells.
Getting Started
To begin using the IntelliJ Platform integration:
Create a new Kotlin Notebook file (
.ipynb
) in your project or as a scratch file using ⌘⇧N on macOS or Ctrl+Shift+N on Windows/Linux.Important: Switch to Run in IDE Process mode in the notebook toolbar.
In the first code cell, declare:
%use intellij-platform
Once executed, the necessary IntelliJ Platform libraries are loaded into the Kotlin Notebook classpath, making them available for import in subsequent cells.
Core Features
UI Rendering
The integration enables direct rendering of UI components within notebook cells. When working with Kotlin UI DSL or standard Swing components, returning them as a response causes immediate rendering with full interactivity.
Use the runInEdt
helper to ensure code execution on the Event Dispatch Thread (EDT) and handle exceptions gracefully:
Resource Management
The integration provides automatic resource management through the IntelliJ Platform's Disposer mechanism. A dedicated notebookDisposable
variable allows registration of elements that need cleanup:
Plugin Loading
By default, only the core IntelliJ Platform is loaded into the classpath. To use other plugins (bundled or installed), explicitly load them using:
Extension Registration
Unlike traditional plugin development with plugin.xml, the integration provides programmatic extension registration:
Global Variables
When the IntelliJ Platform integration is loaded, the following variables are automatically available in your Kotlin Notebook environment. These variables provide access to essential IDE components, configuration information, and management interfaces.
Variable | Type | Description |
---|---|---|
|
| Represents the resolved file system path to the IntelliJ Platform installation directory. |
| Represents an IDE instance, which allows interacting with plugins and resolving their dependencies based on the IDE's configuration. | |
| Represents a disposable used for managing the IntelliJ Platform lifetime of the current notebook. | |
| Represents a plugin descriptor for the plugin created with Kotlin Notebook IntelliJ Platform integration. | |
| Instance of the | |
| Instance of | |
| Lazily initialized property containing current IntelliJ Platform product information. |
Notebook Helpers
Function | Description |
---|---|
| Throws an exception with the specified message, which will be printed as the cell's output. |
| Loads plugins installed in the current IDE into the script context based on their plugin IDs. This method also supports optionally loading plugin classes and class loaders. |
| Runs the given block in the Event Dispatch Thread (EDT). If an exception is thrown, it is displayed in the cell's output. |
IntelliJ Platform Helpers
Function | Description |
---|---|
| Returns the current open |
| Returns the current |
| Registers an extension programmatically for the given extension point. |
| Registers an extension programmatically for the given extension point. |