diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbfb015e..6c9c593e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/build.sbt b/build.sbt index 7e9a54ae..ad44a6e0 100644 --- a/build.sbt +++ b/build.sbt @@ -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' @@ -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. @@ -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 @@ -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", @@ -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() diff --git a/metabrowse-server/src/main/scala/metabrowse/server/MetabrowseServer.scala b/metabrowse-server/src/main/scala/metabrowse/server/MetabrowseServer.scala index 23f0ca33..b089da96 100644 --- a/metabrowse-server/src/main/scala/metabrowse/server/MetabrowseServer.scala +++ b/metabrowse-server/src/main/scala/metabrowse/server/MetabrowseServer.scala @@ -232,10 +232,10 @@ 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") @@ -243,19 +243,19 @@ class MetabrowseServer( } 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) { @@ -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", @@ -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))) diff --git a/project/plugins.sbt b/project/plugins.sbt index 8f3dd576..65048794 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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 )