scalafix
scalafix copied to clipboard
Scala CLI shebang is not handled
Just opening it up here so that I don't forget, but it seems when #!/usr/bin/env -S scala-cli shebang is added scalafix doesn't sort imports.
I will take a look at it probably in April. We usually handle it by just commenting it out for our purposes. Semanticdb is produced correctly there.
Related to https://github.com/scalameta/metals/pull/5942
[info] scala.meta.parsers.ParseException: scala/test/organizeImports/Shebang.sc:1: error: illegal start of definition `identifier`
[info] #!/usr/bin/env -S scala-cli shebang
[info] ^
[info] at scala.meta.internal.parsers.Reporter.syntaxError(Reporter.scala:16)
[info] at scala.meta.internal.parsers.Reporter.syntaxError$(Reporter.scala:16)
[info] at scala.meta.internal.parsers.Reporter$$anon$1.syntaxError(Reporter.scala:22)
[info] at scala.meta.internal.parsers.Reporter.syntaxError(Reporter.scala:17)
[info] at scala.meta.internal.parsers.Reporter.syntaxError$(Reporter.scala:17)
[info] at scala.meta.internal.parsers.Reporter$$anon$1.syntaxError(Reporter.scala:22)
[info] at scala.meta.internal.parsers.ScalametaParser.statSeqBuf(ScalametaParser.scala:4088)
[info] at scala.meta.internal.parsers.ScalametaParser.$anonfun$batchSource$13(ScalametaParser.scala:4296)
[info] at scala.Option.getOrElse(Option.scala:201)
[info] at scala.meta.internal.parsers.ScalametaParser.$anonfun$batchSource$1(ScalametaParser.scala:4296)
[info] ...
We could indeed strip the shebang comment in scalafix-core, but shouldn't this be done upstream in ScalametaParser?
We probably could do that, I think it was just more complex to do on the scalameta side than on the Metals one previously.
fixed by https://github.com/scalameta/scalameta/pull/3812, pending bump
fixed in https://github.com/scalacenter/scalafix/pull/2047, tested via https://github.com/scalacenter/scalafix/commit/b22f829afa0904154d3f58dc7a75152501c2d2f1