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

Scala CLI shebang is not handled #1961

Open
tgodzik opened this issue Mar 12, 2024 · 2 comments
Open

Scala CLI shebang is not handled #1961

tgodzik opened this issue Mar 12, 2024 · 2 comments

Comments

@tgodzik
Copy link
Contributor

tgodzik commented Mar 12, 2024

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 scalameta/metals#5942

@bjaglin
Copy link
Collaborator

bjaglin commented Apr 19, 2024

[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?

@tgodzik
Copy link
Contributor Author

tgodzik commented Apr 19, 2024

We probably could do that, I think it was just more complex to do on the scalameta side than on the Metals one previously.

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

No branches or pull requests

2 participants