Skip to content

Commit e6b6480

Browse files
authored
Merge pull request #3954 from expz/expz-contributing
Close #3933 Improvements to the IntelliJ IDEA getting started guide
2 parents 9053964 + e84683b commit e6b6480

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

docs/docs/contributing/intellij-idea.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,46 @@ its installed on your local machine). Otherwise, specify it by pressing *New*.
2020

2121
![](../../images/idea/idea-sdk.png "Select the JDK")
2222

23-
On the final window we must select which modules we can import. Here, we are presented with the full list of SBT projects
24-
that are defined in Dotty. You can either select all (expect performance degradation by IDEA if you select all) or
23+
Next we must select which modules we can import. IDEA version 2017.1 and earlier presents the full list of SBT modules
24+
that are defined in Dotty. You can either select all (expect performance degradation if you select all) or
2525
select only the `dotty` module. In order to do that, unselect all modules and select on `dotty`. IDEA, then, automatically
2626
selects all the necessary dependencies and you press OK.
2727

2828
![](../../images/idea/idea-sbt.png "Select modules to import")
2929

30+
In IDEA version 2017.2 and later, wait for the project to load. Then right click on `dotty` in the project explorer
31+
and select `Load/Unload Modules...`. Select only `dotty`, accept when IDEA asks to add its dependencies and press OK.
32+
3033
Running/Debugging
3134
-------
3235

33-
To run the compiler you can do it either as an sbt command or via debugging the compiler.
34-
For the first option you can fire up sbt from the `Terminal` window of IDEA or you can do it externally.
35-
For example, to run a test you can write with or without flags:
36+
To run the compiler you can do it either as an sbt command or a shell script. Open an external terminal.
37+
For the first option, a test can be run as follows.
3638

3739
```shell
38-
$ dotc tests/pos/Arrays.scala
40+
$ sbt
41+
> dotc tests/pos/Arrays.scala
3942
```
43+
For the second option, the compiler can be run using a script in the `bin` directory:
4044

41-
If you are interested in debugging the compiler you can enable the necessary agent on the JVM.
42-
This is done in two steps. For the first step you need to pass the
43-
necessary flag to the running VM. For convenience, this is already in comments on the `Build.scala` file under the
44-
`project` directory. The string you need to uncomment is the following:
45-
46-
> `"-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"`
45+
```shell
46+
$ ./bin/dotc tests/pos/Arrays.scala
47+
```
4748

48-
Uncomment the line and reload the project file with the `reload` command on sbt.
49-
Now, each time you run `dotc` the compiler listens at the designated address and waits the agent to connect.
50-
For, the second step you need to create a configuration for Debug through IDEA:
49+
If you are interested in debugging the compiler, you can use a remote debugging configuration.
50+
This is done by launching dotc's JVM with the JDWP agent loaded. To that end, run
51+
```shell
52+
$ ./bin/dotc -debug tests/pos/Arrays.scala
53+
```
54+
Then when dotc starts, it will suspend and wait for a debugger to connect on port `5005`.
55+
Next a configuration for Debug must be created in IDEA:
5156

5257
> Run > Edit Configurations > Add New Configuration > (select) Remote
5358
5459
![](../../images/idea/idea-debug.png "Create a Debug Configuration")
5560

56-
Now every time you run `dotc` you can set your breakpoints and hit the `Debug dotty-debug` button (since we used that name for
57-
the sample configuration above). The default data on the configuration match the enabled agent on the VM so, probably,
61+
Under `Search sources using module's classpath` select `dotty`. Set breakpoints as desired.
62+
Then hit the button whose tooltip says `Debug dotty-debug` (since we used `dotty-debug` for the name of
63+
the sample configuration above) in IDEA to connect the debugger to the JVM and begin debugging. The default data on the debug configuration matches the enabled agent on the VM so, probably,
5864
you will not need to change anything else.
5965

0 commit comments

Comments
 (0)