Skip to content

Commit

Permalink
Handle colons in file names when producing SemanticDB
Browse files Browse the repository at this point in the history
Fixes #15860
  • Loading branch information
kierendavies committed Aug 16, 2022
1 parent e560c2d commit 11cfdae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/semanticdb/Tools.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 11cfdae

Please sign in to comment.