Skip to content

Commit

Permalink
Merge branch 'master' into update/scalameta-4.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Nov 4, 2024
2 parents f02e693 + 52f4d03 commit b763349
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
scala: [2.12.19, 2.13.14]
scala: [2.12.20, 2.13.15]
os: [ubuntu-latest]
java: [11, 8]
steps:
Expand Down
27 changes: 15 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ lazy val Version = new {
"2.13.11",
"2.13.12",
"2.13.13",
"2.13.14"
"2.13.14",
"2.13.15"
)
val scala212Versions = Seq(
"2.12.16",
"2.12.17",
"2.12.18",
"2.12.19"
"2.12.19",
"2.12.20"
)
def scala213 = scala213Versions.last
def scala212 = scala212Versions.last

def mtags = "1.3.2"
def mtags = "1.3.5"
// Important: this should be the exact same version as the one mtags pulls, as mtags uses some scalameta internal APIs,
// and binary compatibility of these APIs isn't guaranteed.
// Get this version with a command like 'cs resolve org.scalameta:mtags_2.13.14:1.3.1 | grep org.scalameta:scalameta'
Expand Down Expand Up @@ -105,8 +107,8 @@ lazy val example = project
"-Xplugin-require:semanticdb"
),
libraryDependencies ++= List(
"org.scalatest" %% "scalatest" % "3.2.18" % Test,
"org.scalacheck" %% "scalacheck" % "1.17.1" % Test,
"org.scalatest" %% "scalatest" % "3.2.19" % Test,
"org.scalacheck" %% "scalacheck" % "1.18.1" % Test,
"org.scalatestplus" %% "scalacheck-1-17" % "3.2.18.0" % Test
),
test := {} // no need to run paiges tests.
Expand All @@ -121,10 +123,11 @@ lazy val server = project
resolvers += Resolver.sonatypeRepo("snapshots"),
libraryDependencies ++= List(
"io.undertow" % "undertow-core" % "2.0.30.Final",
"org.slf4j" % "slf4j-api" % "2.0.13",
"org.slf4j" % "slf4j-api" % "2.0.16",
"org.jboss.xnio" % "xnio-nio" % "3.8.0.Final",
"org.scalameta" % "semanticdb-scalac-core" % Version.scalameta cross CrossVersion.full,
("org.scalameta" %% "mtags" % Version.mtags).cross(CrossVersion.full)
("org.scalameta" %% "mtags" % Version.mtags).cross(CrossVersion.full),
"com.lihaoyi" %% "os-lib" % "0.10.1"
),
(Compile / packageBin) := {
import java.io.FileOutputStream
Expand Down Expand Up @@ -247,7 +250,7 @@ lazy val js = project
webpackConfigFile := Some(baseDirectory.value / "webpack.config.js"),
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.8",
"org.scalatest" %%% "scalatest" % "3.2.18" % Test
"org.scalatest" %%% "scalatest" % "3.2.19" % Test
),
(Compile / npmDevDependencies) ++= Seq(
"clean-webpack-plugin" -> "3.0.0",
Expand Down Expand Up @@ -357,10 +360,10 @@ lazy val tests = project
libraryDependencies ++= List(
"org.scalameta" %% "testkit" % Version.scalameta,
"org.scalameta" % "semanticdb-scalac-core" % Version.scalameta cross CrossVersion.full,
"org.scalatest" %% "scalatest" % "3.2.18",
"org.scalacheck" %% "scalacheck" % "1.17.1",
"org.seleniumhq.selenium" % "selenium-java" % "4.21.0" % IntegrationTest,
"org.slf4j" % "slf4j-simple" % "2.0.13"
"org.scalatest" %% "scalatest" % "3.2.19",
"org.scalacheck" %% "scalacheck" % "1.18.1",
"org.seleniumhq.selenium" % "selenium-java" % "4.23.1" % IntegrationTest,
"org.slf4j" % "slf4j-simple" % "2.0.16"
),
(IntegrationTest / compile) := {
_root_.io.github.bonigarcia.wdm.WebDriverManager.chromedriver.setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,30 +232,30 @@ class MetabrowseServer(
.build()

private def getBytes(exchange: HttpServerExchange): Array[Byte] = {
val path = exchange.getRequestPath.stripSuffix(".gz")
if (path.endsWith("index.workspace")) {
val path = os.SubPath("." + exchange.getRequestPath.stripSuffix(".gz"))
if (path.lastOpt.exists(_.endsWith("index.workspace"))) {
getWorkspace.toByteArray
} else if (path.endsWith(".symbolindexes")) {
} else if (path.lastOpt.exists(_.endsWith(".symbolindexes"))) {
val header = exchange.getRequestHeaders.get("Metabrowse-Symbol")
if (header.isEmpty) {
logger.error(s"no Metabrowse-Symbol header: $exchange")
Array.emptyByteArray
} else {
getSymbol(header.getFirst).toByteArray
}
} else if (path.endsWith(".semanticdb")) {
} else if (path.lastOpt.exists(_.endsWith(".semanticdb"))) {
getSemanticdb(path).toByteArray
} else if (path.endsWith(".map")) {
} else if (path.lastOpt.exists(_.endsWith(".map"))) {
// Ignore requests for sourcemaps.
Array.emptyByteArray
} else {
val actualPath = if (path == "/") "/index.html" else path
val actualPath = if (path == os.sub) os.sub / "index.html" else path
withInputStream(
Thread
.currentThread()
.getContextClassLoader
.getResourceAsStream(
s"metabrowse/server/assets/${actualPath.stripPrefix("/")}"
(os.sub / "metabrowse" / "server" / "assets" / actualPath).toString
)
) { is =>
if (is == null) {
Expand Down Expand Up @@ -301,27 +301,35 @@ class MetabrowseServer(
Workspace(filenames.result().toSeq)
}

private def getSemanticdb(filename: String): TextDocuments = {
val path = filename
.stripPrefix("/semanticdb/")
.stripPrefix("/") // optional '/'
.stripSuffix(".semanticdb")
logger.info(path)
private def getSemanticdb(subPath: os.SubPath): TextDocuments = {
val path = {
val subPath0 =
if (subPath.startsWith(os.sub / "semanticdb"))
subPath.relativeTo(os.sub / "semanticdb").asSubPath
else
subPath
subPath0.lastOpt match {
case Some(name) if name.endsWith(".semanticdb") =>
subPath0 / os.up / name.stripSuffix(".semanticdb")
case _ => subPath0
}
}
logger.info(path.toString)
for {
text <- state.get().source(path).orElse {
text <- state.get().source(path.toString).orElse {
logger.warn(s"no source file: $path")
None
}
doc <- try {
val timeout = TimeUnit.SECONDS.toMillis(10)
val textDocument = if (path.endsWith(".java")) {
val input = Input.VirtualFile(path, text)
val textDocument = if (path.lastOpt.exists(_.endsWith(".java"))) {
val input = Input.VirtualFile(path.toString, text)
t.JavaMtags.index(input, includeMembers = true).index()
} else {
InteractiveSemanticdb.toTextDocument(
global,
text,
filename,
subPath.toString,
timeout,
List(
"-P:semanticdb:synthetics:on",
Expand All @@ -332,7 +340,7 @@ class MetabrowseServer(
Some(textDocument)
} catch {
case NonFatal(e) =>
logger.error(s"compile error: $filename", e)
logger.error(s"compile error: $subPath", e)
None
}
} yield TextDocuments(List(doc.withText(text)))
Expand Down
10 changes: 5 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.5")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.0")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0")

libraryDependencies ++= List(
"io.github.bonigarcia" % "webdrivermanager" % "5.8.0",
"com.thesamet.scalapb" %% "compilerplugin" % "0.11.15",
"io.github.bonigarcia" % "webdrivermanager" % "5.9.2",
"com.thesamet.scalapb" %% "compilerplugin" % "0.11.17",
"org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
)

0 comments on commit b763349

Please sign in to comment.