Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Within test source, IntelliJ IDEA "Cannot find declaration to go to" for type defined in sources #96

Open
andrew-selvia opened this issue Jul 26, 2024 · 2 comments

Comments

@andrew-selvia
Copy link

For an sbt project matrix spanning JS, JVM, and Native, IntelliJ IDEA is capable of fully indexing sources within src/main. Any types defined within the sources can be used by tests within src/test. In other words, sbt test works just fine.

However, the types defined within src/main are seemingly unnavigable from src/test. If you select Navigate > GoTo (i.e., ⌘-click) on a type defined in the sources, an alert says "Cannot find declaration to go to".

Workaround: If the JS & Native axes are removed from the project matrix, navigation to source files works.

It's unclear whether this is an issue with sbt-projectmatrix or the IntelliJ IDEA Scala plugin. It could also easily be user error (apologies, if so). Please let me know if this is a known issue or there is a more appropriate workaround.

Versions:

  • Scala: 3
  • sbt: 1.10.1
  • sbt-projectmatrix: 0.10.0
  • IntelliJ IDEA: 2024.2 Beta
@sfali
Copy link

sfali commented Nov 10, 2024

Same issue here. It seems compiled classes goes under jvm-2.12, jvm-2-13, and jvm-3` and hence it fails recognize classes.

@keynmol
Copy link
Contributor

keynmol commented Nov 12, 2024

I'm inclined to think it's an IntelliJ bug - I was able to reproduce by trying to go to definition of "TypeClass" here: https://github.com/indoorvivants/scala3-library-template/blob/main/modules/core/src/test/scala/ExampleTests.scala#L5, with project imported using SBT BSP.

Metals (using SBT BSP) imported project fine and go to definition works, so sbt-projectmatrix doesn't screw with BSP configuration it seems.

Perhaps IntelliJ is making incorrect assumptions on the position of the target folder – not taking that information from the buildtool, but instead using some pre-defined location.

A bit of spelunking in the intellij-scala repo unearthed this: https://github.com/JetBrains/intellij-scala/blob/8f9bcf8f8239f464af726a85dfea278ecb63209c/sbt/sbt-impl/src/org/jetbrains/sbt/project/ExternalSourceRootResolution.scala#L533-L561 which makes me suspect that this custom configuration is broken somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants