intellij icon indicating copy to clipboard operation
intellij copied to clipboard

Nested package declarations in Scala are highlighted as errors

Open odisseus opened this issue 3 years ago • 2 comments

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.

Screenshot 2022-04-08 at 08 03 28

Here's a minimum example project that showcases the problem. example.zip

odisseus avatar Apr 08 '22 06:04 odisseus

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.

jesseschalken avatar Jun 14 '22 15:06 jesseschalken

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.

liucijus avatar Sep 22 '22 16:09 liucijus

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.

github-actions[bot] avatar Jun 01 '23 02:06 github-actions[bot]

The issue is still there. IntelliJ 2023.1.2, Bazel plugin 3c68f0b663468524fce2b70073d6fae2d44d01e5.

odisseus avatar Jun 01 '23 09:06 odisseus