From 11cfdae6696d7aa00f7c85c614c1842aeadc970d Mon Sep 17 00:00:00 2001 From: Kieren Davies Date: Mon, 15 Aug 2022 12:22:46 +0200 Subject: [PATCH] Handle colons in file names when producing SemanticDB Fixes #15860 --- compiler/src/dotty/tools/dotc/semanticdb/Tools.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala b/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala index ffd156672cc6..b000a7b80790 100644 --- a/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala +++ b/compiler/src/dotty/tools/dotc/semanticdb/Tools.scala @@ -12,7 +12,11 @@ object Tools: def mkURIstring(path: Path): String = // Calling `.toUri` on a relative path will convert it to absolute. Iteration through its parts instead preserves // the resulting URI as relative. - val uriParts = for part <- path.asScala yield new java.net.URI(null, null, part.toString, null) + // To prevent colon `:` from being treated as a scheme separator, prepend a slash `/` to trick the URI parser into + // treating the part as an absolute path, and then remove it afterwards. + val uriParts = + for part <- path.asScala + yield new java.net.URI(null, null, "/" + part.toString, null).toString().stripPrefix("/") uriParts.mkString("/") /** Load SemanticDB TextDocument for a single Scala source file