Setting up IntelliJ IDEA
The IntelliJ Ballerina plugin provides the Ballerina development capabilities in IntelliJ IDEA. The below sections include instructions on how to download, install, and use the features of the IntelliJ plugin.
Setting Up the Prerequisites
You need IntelliJ IDEA installed.
Note: Your IntelliJ IDE version should be compatible with the corresponding Ballerina plugin version (i.e., the same as the Ballerina distribution version) as shown in the below table.
Plugin Version | Platform Version Compatibility |
---|---|
0.8.0 - 0.8.2 | IntelliJ IDEA 2016.3 - 2016.4 |
0.8.3 - 0.981.0 | IntelliJ IDEA 2016.3 - 2017.2 |
0.982.0 - 0.991.0 | IntelliJ IDEA 2017.3 - 2018.2 |
0.991.1 - 1.2.1 | IntelliJ IDEA 2018.3 - 2019.3 |
1.2.2+ | IntelliJ IDEA 2018.3+ |
Installing the Plugin
Use either of the below approaches to install the IntelliJ Ballerina plugin.
Installing via the IntelliJ IDE
- Open IntelliJ, click IntelliJ IDEA in the top menu, click Preferences, and then click Plugins.
Tip: If you are using Ubuntu/Windows, click File, click Settings, and then click Plugins.
- In the search bar, type “Ballerina” and press the Enter key.
- Click Install, and then click Accept.
- Click Restart IDE, and then click Restart.
This downloads the plugin and installs it.
Installing Using the ZIP File
Follow the steps below to install the plugin using its ZIP file.
Obtaining the ZIP File
Follow either of the below approaches to obtain the ZIP file of the Ballerina plugin.
Downloading from the JetBrains Plugin Repository
Download the IntelliJ Ballerina plugin.
Building from the Source
Follow the steps below to obtain the ZIP file by building it from its source.
- Clone the ballerina-lang GitHub repo.
- In a new Command Line tab, navigate to the source directory of the plugin (i.e., the
<CLONED_BALLERINA_DIRECTORY>/tool-plugins/intellij
directory), and execute the below command.Info: In the above step,
<CLONED_BALLERINA_DIRECTORY>
refers to the path of the ballerina-lang Git repository, which you cloned locally. Tip: You need to install the Gradle Build Tool to execute the below command../gradlew buildPlugin
This creates the /build/distributions/ballerina-intellij-idea-plugin-[VERSION].zip
file locally in the <CLONED_BALLERINA_DIRECTORY>/tool-plugins/intellij
directory.
Installing the ZIP File via the IDE
After obtaining the ZIP file using either of the above approaches, follow the steps below to install it using the IntelliJ IDE.
- Open IntelliJ, click IntelliJ IDEA in the top menu, click Preferences, and then click Plugins.
Tip: If you are using Ubuntu/Windows, click File, click Settings, and then click Plugins.
- Click the cogwheel icon, and then click Install plugin from disk….
- Browse and select the ZIP file of the plugin you downloaded.
Important: Make sure you install the ZIP file and not the extracted JAR files. This is because the ZIP file contains an additional library that is required by the plugin to function as expected.
- Click the Installed tab, click Restart IDE, and then click Restart.
Using the Plugin
The below sections include information on using the IntelliJ Ballerina plugin to write Ballerina programs.
- Creating a new Ballerina project
- Setting up Ballerina SDK for an existing project
- Creating a new Ballerina file
- Configuring the plugin settings
Using the Features of the Plugin
The below sections include information on the various capabilities that are facilitated by the IntelliJ Ballerina plugin for the development process.
- Running Ballerina programs
- Debugging Ballerina programs
- Viewing the sequence diagram
- Importing modules on the fly
- Importing unambiguous modules
- Formatting Ballerina codes
- Viewing documentation
- Adding annotation fields via suggestions
- Using file templates
- Using code snippet templates
- Checking spellings
- Analyzing semantics
- Code folding
- Go to definition