From 4fba87a7572c1b78a45330d58e603b873336e09c Mon Sep 17 00:00:00 2001 From: MkDev11 Date: Sun, 11 Jan 2026 13:37:13 -0800 Subject: [PATCH] fix: Filter out JAR paths in BSP diagnostics on Windows (#8482) When Java compiler generates warnings about missing annotations from JAR files, the path format is jar:file:///C:/... which causes InvalidPathException on Windows due to the : character. The fix filters out jar: paths in toDocument(), similar to how fake positions like are already filtered out. This prevents the exception and allows compilation to continue. Diagnostics for files inside JARs are not shown in the IDE, which is correct behavior since they cannot be edited. Fixes #7665 Generated-by: Cascade (AI pair programmer) --- .../scala/sbt/internal/server/BuildServerReporter.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/internal/server/BuildServerReporter.scala b/main/src/main/scala/sbt/internal/server/BuildServerReporter.scala index 895ad1477..4c512f9c8 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerReporter.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerReporter.scala @@ -92,9 +92,11 @@ final class BuildServerReporterImpl( private val problemsByFile = mutable.Map[Path, Vector[Problem]]() // sometimes the compiler returns a fake position such as - // on Windows, this causes InvalidPathException (see #5994 and #6720) + // or a JAR file path like jar:file:///C:/... + // on Windows, this causes InvalidPathException (see #5994, #6720, and #7665) private def toDocument(ref: VirtualFileRef): Option[TextDocumentIdentifier] = - if (ref.id().contains("<")) None + val id = ref.id() + if id.contains("<") || id.startsWith("jar:") then None else Some(TextDocumentIdentifier(converter.toPath(ref).toUri)) /**