scala-cli
scala-cli copied to clipboard
BSP sets the source folder wrong in the context of the sources' package in IntelliJ
Version(s) 0.1.12
Describe the bug Scala CLI's BSP marks the sources directory in IDEA IntelliJ to the parent directory of the sources, regardless of the package structure. This messes up the IntelliJ project structure and makes navigating the sources less intuitive. Technically, everything will compile and run as normal, but it's not great UX when working in IntelliJ.
To Reproduce For a structure like this
▶ tree -A
.
└── src
└── Main.scala
1 directory, 1 file
I setup BSP with scala-cli
scala-cli setup-ide .
then, I add a package declaration in Main.scala and decide to mirror the package structure in directories.
As a result, I have a structure like this:
▶ tree -A
.
└── src
└── com
└── github
└── gedochao
└── Main.scala
Now, a workspace reload with Scala CLI's BSP messes up my project structure by changing the sources directory to the immediate parent directory of Main.scala
Now, this is curious. If I add another source in the same package, one level higher, BSP will set the sources dir one level higher as well after a reload.
▶ tree -A
.
└── src
└── com
└── github
├── AnotherObject.scala
└── gedochao
└── Main.scala
4 directories, 2 files
So I'm assuming it's setting the sources directory to the parent directory of the source closest to root.
Known workarounds
I can theoretically reset the sources directory to the package root's parent directory, but I'd have to redo it after every single BSP reload, which is simply impractical.
I can also add a mock source file outside of the package (in (default) package), so that the source root is picked where it should, but that's not ideal, either.
So you basically end up ignoring it and accepting that the project structure identified by IntelliJ isn't correct.
Expected behaviour BSP should set the sources directory in IntelliJ to the parent of the package root.