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

bugfix: fix worksheets with 3.4.0 #6212

Merged
merged 3 commits into from Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -150,7 +150,8 @@ final class Embedded(
pathString.contains("mdoc") ||
pathString.contains("scalameta") ||
pathString.contains("metaconfig") ||
pathString.contains("diffutils")
pathString.contains("diffutils") ||
pathString.contains("scala-sbt")
}
val urls = runtimeClasspath.iterator.map(_.toUri().toURL()).toArray
new URLClassLoader(urls, parent)
Expand Down
@@ -1,8 +1,11 @@
package tests.feature

import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.metals.{BuildInfo => V}
import scala.meta.internal.semver.SemVer

import coursierapi.Complete

class Worksheet211LspSuite extends tests.BaseWorksheetLspSuite(V.scala211)

class Worksheet3LspSuite extends tests.BaseWorksheetLspSuite(V.scala3) {
Expand All @@ -25,4 +28,28 @@ class LatestWorksheet3LspSuite
"""given str: String = """""
}

class Worksheet3NextSuite
extends tests.BaseWorksheetLspSuite(Worksheet3NextSuite.scala3Next) {
override def versionSpecificCodeToValidate: String =
"""given str: String = """""
}

object Worksheet3NextSuite {
def scala3Next: String =
Complete
.create()
.withInput("org.scala-lang:scala3-compiler_3:")
.complete()
.getCompletions()
.asScala
.toList
.reverse
.collectFirst { version =>
SemVer.Version.fromString(version) match {
case SemVer.Version(_, _, _, None, None, None) => version
}
}
.get
}

class Worksheet212LspSuite extends tests.BaseWorksheetLspSuite(V.scala212)
8 changes: 7 additions & 1 deletion tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala
Expand Up @@ -10,6 +10,7 @@ import scala.meta.internal.metals.clients.language.MetalsSlowTaskResult
import scala.meta.internal.metals.codeactions.CreateNewSymbol
import scala.meta.internal.metals.codeactions.ImportMissingSymbol
import scala.meta.internal.metals.{BuildInfo => V}
import scala.meta.internal.semver.SemVer

abstract class BaseWorksheetLspSuite(
scalaVersion: String
Expand Down Expand Up @@ -855,7 +856,12 @@ abstract class BaseWorksheetLspSuite(
_ = assertNoDiff(noCompletions, "")
} yield ()
}
if (ScalaVersions.isScala3Version(scalaVersion))
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore this for next?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ignored only for 3.4.0.

ScalaVersions.isScala3Version(scalaVersion) && !SemVer.isLaterVersion(
V.scala3,
scalaVersion,
)
)
test("import-missing-symbol") {
cleanWorkspace()
val path = "a/src/main/scala/foo/Main.worksheet.sc"
Expand Down