Was this page helpful?

Developer IntelliJ Setup (for Kotlin)

The IntelliJ environment allows running Kotlin-based code generators (e.g., Cpp code generator), which is currently impossible for the Eclipse environment. Like Eclipse, IntelliJ provides a debugger UI useful for debugging the code generation routines.


IntelliJ Installation

Go to the IntelliJ download page and install IntelliJ for your operating system. The community edition (CE) of IntelliJ should be enough as a development environment for Lingua Franca.

Cloning lingua-franca repository

Clone the lingua-franca repository into your working directory. For example, into a directory called lingua-franca-intellij using the following command:

$ git clone git@github.com:lf-lang/lingua-franca.git lingua-franca-intellij

Opening lingua-franca as IntelliJ Project

Open IntelliJ IDE. At the startup screen, click Open. Or, at the top menu bar, click File -> Open.

startup screen

In the pop-up dialog, navigate to the cloned Git repository, and click Open.

open project

If you see a pop-up saying “Maven build scripts found” after opening the repository as an IntelliJ project, click Skip since we want to use Gradle instead of Maven in this setup.

skip maven build

Importing Gradle Project

The next step is to load the Gradle configs for building and running Lingua Franca tasks in IntelliJ.

You might see a pop-up asking if you want to load the project as Gradle. If so, click Yes or OK.

However, in many cases, you may not see it. You can import the Gradle project by navigating to the build.gradle file in the root directory of the lingua-franca repository. Right-click build.gradle, then click Import Gradle Project in the drop-down list as shown below.

import gradle project

If you are prompted to a pop-up window asking if you trust the Gradle project, click Trust Project.

trust gradle project

Once the repository is imported as a Gradle project, you will see a Gradle tab on the right.

You may see a message saying that Gradle project indexing is in progress at the bottom. Indexing may take a few minutes.

Once the indexing finishes, you can expand the Gradle project and see the set of Tasks.

expand gradle tab

Setting Up Run Configuration

You can set up a run configuration for running and debugging various Gradle tasks from the Gradle tab, including the code generation through LFC. To set up a run configuration for runLfc task, right-click on runLfc under Gradle’s Tasks -> application and click Modify Run Configuration. This will create a custom run/debug configuration for you.

modify run config

In the Run/Debug Configurations dialog, click on the text box next to Tasks: and append args to specify the LF target. For example, runLfc --args '../example/Cpp/src/CarBrake/CarBrake.lf' Then click OK.

run config lf program

You will see a new run/debug config added to the top menu bar, as shown below. You can always change the config, for example, changing the args, by clicking Edit Configurations via a drop-down menu.

new runlfc config

Running and Debugging

Using the newly added config, you can run and debug the code generator by clicking the play button and the bug button.

run debug buttons

Set up breakpoints before starting the debugger by clicking the space right next to the line numbers. While debugging, you can run code step-by-step by using the debugger tools.

debugger screen

Lingua Franca is an open source project. Help us improve these pages by sending a Pull Request

Contributors to this page:
Eeal  (3)
ARAnirudh Rengarajan  (2)

Last updated: May 27, 2022