Scala Plugin for IntelliJ IDEA
The plugin adds support for the Scala language:
- Coding assistance (highlighting, completion, formatting, refactorings, etc.)
- Navigation, search, information about types and implicits
- Integration with sbt and other build tools
- Testing frameworks support (ScalaTest, Specs2, uTest)
- Scala debugger, worksheets and Ammonite scripts
(note that HOCON support was moved to a separate plugin)
To get information about how to install and use this plugin in IDEA, please use IntelliJ IDEA online help
If you found a bug, please report it on our issue tracker
If you want to contribute, please see our intro to the Scala plugin internals.
Setting up the project
In order to take part in Scala plugin development, you need:
- IntelliJ IDEA 2021.3 or higher with a compatible version of Scala plugin
- JDK 11
- (optional but recommended)
Enable internal mode in IDEA to get access to helpful internal actions and debug information
- Clone this repository to your computer
$ git clone https://github.com/JetBrains/intellij-scala.git
Open IntelliJ IDEA, select
File -> New -> Project from existing sources, point to the directory where the Scala plugin repository is and then import it as sbt project.
In the next step, select JDK 11 as project JDK (create it from an installed JDK if necessary).
scalaCommunityrun configuration and select the
Debugbutton to build and start a development version of IDEA with the Scala plugin.
Browsing IntelliJ Platform sources
When loading Scala Plugin project in sbt, the IntelliJ platform is downloaded to
IntelliJ platform sources should be automatically attached after project has been imported and indices have been built.
However, sometimes this doesn't happen and the sources are not attached. As a result you see decompiled code when opening a Platform API class. To fix this you can invoke "Attach Intellij Sources" action (you need to enable internal mode to access this action)
To run tests properly, the plugin needs to be packaged. On the sbt shell:
The "fast tests" can take over an hour. To get a quick feedback on project health, run only the type inference tests:
Generating test coverage reports
You might want to generate a test coverage report for a given package. It can be done by running for example the following:
sbt "project scala-impl;set coverageEnabled := true;project scalaCommunity;testOnly org.jetbrains.plugins.scala.codeInspection.unusedInspections.*;scala-impl/coverageReport"
Close to the very tail of the output of this command you will find a line that gives you the location of the generated report, for example:
[info] Written HTML coverage report [/Users/alice/intellij-scala/scala/scala-impl/target/scala-2.13/scoverage-report/index.html]
Note that in order to continue working from IntelliJ IDEA again you need to perform Build > Rebuild Project.
GitHub Actions build
The project is configured to build and run the typeInference tests and fast tests with Github Actions. The full test suite isn't run to avoid really long build times.
Running the plugin
The easiest way to try your changes is typically to launch the
scalaCommunity run configuration which is created
when you set up the project as described above.
As a standalone plugin
To run and distribute a modified version of the plugin in a regular IntelliJ instance, you need to package it.
- on the sbt shell, run
packageArtifactZip. This will output the generated plugin zip location (typically into
- In IntelliJ, open Preferences, section Plugins, choose "Install plugin from disk..." and navigate to the scala-plugin.zip
- Restart IntelliJ
Investigation performance issues
- There is a "Scala plugin profiler" tool window to track invocations of methods with
org.jetbrains.plugins.scala.macroAnnotationspackage) in real time. The tool window is available in internal mode or if
-Dinternal.profiler.tracing=trueis passed to IDEA using custom VM options