The plugin adds support for the Scala language to IntelliJ IDEA.
It enables multiple features such as:
(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 have any question about the Scala plugin, we'd be glad to answer it in our discord channel
If you found a bug, please report it on our issue tracker
Please see CONTRIBUTING.md
In order to take part in Scala plugin development, you need:
$ git clone https://github.com/JetBrains/intellij-scala.git
Open IntelliJ IDEA. From the Welcome screen or File
menu, click Open
, and point to
the directory where you cloned the Scala plugin sources. It will be automatically imported as a sbt project.
In the next step, select JDK 17 as project JDK (create it from an installed JDK if necessary).
Select the scalaCommunity
run configuration and select the Run
or Debug
button to build and start a
development version of IDEA with the Scala 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.
Under the hood it will launch IntelliJ IDEA with pre-installed Scala Plugin, built from sources.
To run and distribute a modified version of the plugin in a regular IntelliJ instance, you need to package it.
packageArtifactZip
. This will output the generated plugin zip location
(typically into <project directory>/target/scala-plugin.zip
).To run tests properly, the plugin needs to be packaged. On the sbt shell:
packageArtifact
runFastTests
The "fast tests" can take over an hour. To get a quick feedback on project health, run only the type inference tests:
> runTypeInferenceTests
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.
Error object BuildInfo is already defined ...
during compilation of the project
BuildInfo is an sbt plugin that exposes some of the sbt build metadata to the main project. We use it to forward some dependencies versions from the build sources to main project sources. Sometimes during import this generated source root is added to the bsp
and sbt-impl
modules multiple times. Make sure it's only included once by removing duplicates. This can be done in File > Project Structure...
.
Can't browse IntelliJ Platform sources
When loading Scala Plugin project in sbt, the IntelliJ platform is downloaded to <home>/.ScalaPluginIC/sdk/<sdk version>/
.
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.
Solution:
Invoke "Attach Intellij Sources" action (you need to enable internal mode to access this action
After building the project you see git local changes in ImportsPanel.java
(or similar files). All IdeBorderFactory.PlainSmallWithIndent
are replaced with BorderFactory
Solution: enable internal mode.
UI Designer uses different border class in internal mode, see com.intellij.uiDesigner.make.FormSourceCodeGenerator#borderFactoryClassName
Unexpected local git changes in uiDesigner.xml
or other files in .idea directory
It may happen due to disable internal mode or by enabling it after/during setup.
The solution to this problem might be to revert these changes, enable internal mode (if it has not already been done) and restart IntelliJ.
The Scala plugin is not loaded when running the scalaCommunity
Run Configuration. Unfortunately, there can be multiple reasons for this, like an improperly packaged plugin which cannot be loaded by IDEA at runtime.
Check the list of project modules in File > Project Structure...
and make sure that they don't have a name that starts with scala.<module name>
(e.g. scala.structure-view
). This is a bug in the sbt import process.
If there are modules like this, then remove all modules from the project (in the same Project Structure window) and reimport the project <sbt tab> > Reload All sbt Projects
.
@Cached*
or @Measure
annotations (from org.jetbrains.plugins.scala.macroAnnotations
package) in real time. The tool window is available in internal mode or if -Dinternal.profiler.tracing=true
is passed to IDEA using custom VM optionsYou 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.declarationRedundancy.*;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.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。