Nested package declarations in Scala are highlighted as errors
Scala allows multiple package declarations in the same file. In the following example, the full name of the class is going to be foo.bar.Baz:
package foo
package bar
class Baz {}
According to the Scala conventions, a file with this code should be located at foo/bar/Baz.scala. However, the Bazel plugin marks the package declarations as mismatched with the file path.
Here's a minimum example project that showcases the problem. example.zip
If it's any help the code for this is here:
https://github.com/bazelbuild/intellij/blob/e8fa25e29f338c6e089fccec8dfcfe50f3c37971/java/src/com/google/idea/blaze/java/sync/source/JavaSourcePackageReader.java#L66-L71
which is used used here:
https://github.com/bazelbuild/intellij/blob/f894c76e3f492cf9322a9142b43fc0cf2526b39f/java/src/com/google/idea/blaze/java/sync/source/SourceDirectoryCalculator.java#L102-L106
It's just grabbing the first line that looks like package ... and using that to infer the source roots.
Are multiple packages objects handled correctly with other build tools in Intelij, like SBT? I wonder if there is something missing in Bazel plugin in regards to Scala support, or is it an issue in Scala plugin.
Thank you for contributing to the IntelliJ repository! This issue has been marked as stale since it has not had any activity in the last 6 months. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-maintainer". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.
The issue is still there. IntelliJ 2023.1.2, Bazel plugin 3c68f0b663468524fce2b70073d6fae2d44d01e5.