-
Notifications
You must be signed in to change notification settings - Fork 317
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
Use coursier completions to handle backpublished mtags #4606
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I just have some minor questions
else Some(scalaVer) | ||
}.toOption.flatten | ||
} | ||
.toParArray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.toParArray | |
.distinct | |
.toParArray |
We can have duplicates here, maybe it's worth doing distinct
before next api calls
_.startsWith("2.") | ||
)).distinct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_.startsWith("2.") | |
)).distinct | |
_.startsWith("2.") | |
)) |
_.startsWith("3.") | ||
)).sorted.distinct.mkString(", ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_.startsWith("3.") | |
)).sorted.distinct.mkString(", ") | |
_.startsWith("3.") | |
)).sorted.mkString(", ") |
|
||
import scala.collection.parallel._ | ||
|
||
val additional = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can wrap it in Future
and do something like
val additional =
try Await.result(additionalFuture, 10.seconds)
catch {
case _: Throwable => Nil
}
So when we don't get response from coursier we still show other supported versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is an improvement for sure, thanks for looking into this! I left some comments.
.flatMap { case artif => | ||
Try { | ||
val scalaVer = artif.stripPrefix("mtags_") | ||
val List(epoch, major, rest) = scalaVer.split("\\.", 3).toList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use SemVer
to parse the version.
import org.eclipse.lsp4j.jsonrpc.Launcher | ||
|
||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
if (args.exists(Set("-v", "--version", "-version"))) { | ||
val api: Complete = coursierapi.Complete | ||
.create() | ||
.withInput("org.scalameta:mtags") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem I see is that it will not work for snapshot versions of Metals. The alternative would be something similar to my super fun workaround here: https://github.com/scalameta/metals/blob/main/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala#L119
This has been inactive for a while so I'm going to mark as a draft. @keynmol if you dive back into please do ping us for another review. |
Users often refer to the output of
metals --version
(in vim/emacs and may be others) to ensure their version of Scala is supported.With mtags being backpublished, that output is often out of date.
This PR is to start a conversation about may be detecting backpublished mtags and showing the user the full set of supported version?