Skip to content

Commit a3c6495

Browse files
Merge branch 'master' into update/scala-library-2.13.15
2 parents 5261a38 + 94373e4 commit a3c6495

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
scala: [2.12.19, 2.13.15]
29+
scala: [2.12.20, 2.13.15]
3030
os: [ubuntu-latest]
3131
java: [11, 8]
3232
steps:

build.sbt

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ lazy val Version = new {
1414
"2.12.16",
1515
"2.12.17",
1616
"2.12.18",
17-
"2.12.19"
17+
"2.12.19",
18+
"2.12.20"
1819
)
1920
def scala213 = scala213Versions.last
2021
def scala212 = scala212Versions.last
@@ -125,7 +126,8 @@ lazy val server = project
125126
"org.slf4j" % "slf4j-api" % "2.0.16",
126127
"org.jboss.xnio" % "xnio-nio" % "3.8.0.Final",
127128
"org.scalameta" % "semanticdb-scalac-core" % Version.scalameta cross CrossVersion.full,
128-
("org.scalameta" %% "mtags" % Version.mtags).cross(CrossVersion.full)
129+
("org.scalameta" %% "mtags" % Version.mtags).cross(CrossVersion.full),
130+
"com.lihaoyi" %% "os-lib" % "0.10.1"
129131
),
130132
(Compile / packageBin) := {
131133
import java.io.FileOutputStream
@@ -360,7 +362,7 @@ lazy val tests = project
360362
"org.scalameta" % "semanticdb-scalac-core" % Version.scalameta cross CrossVersion.full,
361363
"org.scalatest" %% "scalatest" % "3.2.19",
362364
"org.scalacheck" %% "scalacheck" % "1.18.1",
363-
"org.seleniumhq.selenium" % "selenium-java" % "4.23.0" % IntegrationTest,
365+
"org.seleniumhq.selenium" % "selenium-java" % "4.23.1" % IntegrationTest,
364366
"org.slf4j" % "slf4j-simple" % "2.0.16"
365367
),
366368
(IntegrationTest / compile) := {

metabrowse-server/src/main/scala/metabrowse/server/MetabrowseServer.scala

+26-18
Original file line numberDiff line numberDiff line change
@@ -232,30 +232,30 @@ class MetabrowseServer(
232232
.build()
233233

234234
private def getBytes(exchange: HttpServerExchange): Array[Byte] = {
235-
val path = exchange.getRequestPath.stripSuffix(".gz")
236-
if (path.endsWith("index.workspace")) {
235+
val path = os.SubPath("." + exchange.getRequestPath.stripSuffix(".gz"))
236+
if (path.lastOpt.exists(_.endsWith("index.workspace"))) {
237237
getWorkspace.toByteArray
238-
} else if (path.endsWith(".symbolindexes")) {
238+
} else if (path.lastOpt.exists(_.endsWith(".symbolindexes"))) {
239239
val header = exchange.getRequestHeaders.get("Metabrowse-Symbol")
240240
if (header.isEmpty) {
241241
logger.error(s"no Metabrowse-Symbol header: $exchange")
242242
Array.emptyByteArray
243243
} else {
244244
getSymbol(header.getFirst).toByteArray
245245
}
246-
} else if (path.endsWith(".semanticdb")) {
246+
} else if (path.lastOpt.exists(_.endsWith(".semanticdb"))) {
247247
getSemanticdb(path).toByteArray
248-
} else if (path.endsWith(".map")) {
248+
} else if (path.lastOpt.exists(_.endsWith(".map"))) {
249249
// Ignore requests for sourcemaps.
250250
Array.emptyByteArray
251251
} else {
252-
val actualPath = if (path == "/") "/index.html" else path
252+
val actualPath = if (path == os.sub) os.sub / "index.html" else path
253253
withInputStream(
254254
Thread
255255
.currentThread()
256256
.getContextClassLoader
257257
.getResourceAsStream(
258-
s"metabrowse/server/assets/${actualPath.stripPrefix("/")}"
258+
(os.sub / "metabrowse" / "server" / "assets" / actualPath).toString
259259
)
260260
) { is =>
261261
if (is == null) {
@@ -301,27 +301,35 @@ class MetabrowseServer(
301301
Workspace(filenames.result().toSeq)
302302
}
303303

304-
private def getSemanticdb(filename: String): TextDocuments = {
305-
val path = filename
306-
.stripPrefix("/semanticdb/")
307-
.stripPrefix("/") // optional '/'
308-
.stripSuffix(".semanticdb")
309-
logger.info(path)
304+
private def getSemanticdb(subPath: os.SubPath): TextDocuments = {
305+
val path = {
306+
val subPath0 =
307+
if (subPath.startsWith(os.sub / "semanticdb"))
308+
subPath.relativeTo(os.sub / "semanticdb").asSubPath
309+
else
310+
subPath
311+
subPath0.lastOpt match {
312+
case Some(name) if name.endsWith(".semanticdb") =>
313+
subPath0 / os.up / name.stripSuffix(".semanticdb")
314+
case _ => subPath0
315+
}
316+
}
317+
logger.info(path.toString)
310318
for {
311-
text <- state.get().source(path).orElse {
319+
text <- state.get().source(path.toString).orElse {
312320
logger.warn(s"no source file: $path")
313321
None
314322
}
315323
doc <- try {
316324
val timeout = TimeUnit.SECONDS.toMillis(10)
317-
val textDocument = if (path.endsWith(".java")) {
318-
val input = Input.VirtualFile(path, text)
325+
val textDocument = if (path.lastOpt.exists(_.endsWith(".java"))) {
326+
val input = Input.VirtualFile(path.toString, text)
319327
t.JavaMtags.index(input, includeMembers = true).index()
320328
} else {
321329
InteractiveSemanticdb.toTextDocument(
322330
global,
323331
text,
324-
filename,
332+
subPath.toString,
325333
timeout,
326334
List(
327335
"-P:semanticdb:synthetics:on",
@@ -332,7 +340,7 @@ class MetabrowseServer(
332340
Some(textDocument)
333341
} catch {
334342
case NonFatal(e) =>
335-
logger.error(s"compile error: $filename", e)
343+
logger.error(s"compile error: $subPath", e)
336344
None
337345
}
338346
} yield TextDocuments(List(doc.withText(text)))

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0")
2-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")
2+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.0")
33
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.0")
44
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7")
55
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")

0 commit comments

Comments
 (0)