scalafix icon indicating copy to clipboard operation
scalafix copied to clipboard

Better IntelliJ support when working on scalafix

Open bjaglin opened this issue 3 years ago • 5 comments

Since the introduction of sbt-project-matrix in https://github.com/scalacenter/scalafix/pull/1528, there are compilation errors in IntelliJ when working on scalafix itself (apparently for both classic & BSP integrations), which prevents running tests from the IDE.

This is also true for projects bootstrapped with https://github.com/scalacenter/scalafix.g8.

bjaglin avatar Jun 29 '22 10:06 bjaglin

A first solution would be to only export some of the modules of the matrix as recommended in https://github.com/sbt/sbt-projectmatrix/issues/25#issuecomment-623850021.

bjaglin avatar Jun 29 '22 10:06 bjaglin

What are the BSP errors that you get? Maybe it's fixable on the Bloop/sbt side?

tgodzik avatar Jun 29 '22 10:06 tgodzik

@tgodzik I didn't get the time to look at it myself.

@rvacaru can you report your problems here?

bjaglin avatar Jun 29 '22 10:06 bjaglin

Just checked and I don't get any errors with Bloop + Metals. Project matrix might be problematic for Intellij as it doesn't like multiple targets with the same directory.

tgodzik avatar Jun 29 '22 10:06 tgodzik

@tgodzik @bjaglin I've just started working on scalafix with both Intellij and VS Code, so far these are my findings when comparing the IDEs:

  • Just looking at ExplicitResultTypes.scala

    • Intellij: line 9 import buildinfo.RulesBuildInfo is not resolved, even after running sbt compile on the whole scalafix
    • VS Code: the import works and ctrl click on RulesBuildInfo navigates to the scala file
  • Looking at ExplicitResultTypesBug.scala (only in the output folder, not the input)

    • Intellij:
      • line 4 import scala.reflect.runtime.universe._ says runtime isn't a member of reflect
      • line 9 type ClassMirror not found
    • VS Code: runtime package is recognized when hoovering on it and ctrl click on ClassMirror navigates to it
  • Looking at Compat.scala objects

    • Intellij errors SeqView expects only 1 arg, but finds 2 (points to scala-library-2.13.8 jar instead of the 2.11 or 2.12 versions
    • VS Code works as expected
  • Running or debugging ScalafixImplSuite

    • Intellij fails building with Compat is already defined as object Compat
    • VS Code runs and debugs are working fine

rvacaru avatar Jul 01 '22 09:07 rvacaru