Skip to content

Commit 09ca3f2

Browse files
committed
Handle colons in file names when producing SemanticDB
Fixes #15860
1 parent e560c2d commit 09ca3f2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/semanticdb/Tools.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ object Tools:
1212
def mkURIstring(path: Path): String =
1313
// Calling `.toUri` on a relative path will convert it to absolute. Iteration through its parts instead preserves
1414
// the resulting URI as relative.
15-
val uriParts = for part <- path.asScala yield new java.net.URI(null, null, part.toString, null)
15+
// To prevent colon `:` from being treated as a scheme separator, prepend a slash `/` to trick the URI parser into
16+
// treating the part as an absolute path, and then remove it afterwards.
17+
val uriParts =
18+
for part <- path.asScala
19+
yield new java.net.URI(null, null, "/" + part.toString, null).getPath().nn.stripPrefix("/")
1620
uriParts.mkString("/")
1721

1822
/** Load SemanticDB TextDocument for a single Scala source file

0 commit comments

Comments
 (0)