-
Notifications
You must be signed in to change notification settings - Fork 63
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. IntelliJ also provides a debugger UI useful for debugging the code generation routines.
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.
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
Open IntelliJ IDE. At the startup screen, click Open. Or, at the top menu bar, click File -> Open.
In the pop-up dialog, navigate to the cloned Git repository, and click Open.
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.
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.
If you are prompted to a pop-up window asking if you trust the Gradle project, click Trust 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.
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.
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.
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.
Using the newly added config, you can run and debug the code generator by clicking the play button and the bug button.
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.