Skip to content

Commit 6e66cd6

Browse files
committed
Fix scala#3373 and scala#3349 - windows filenames
1 parent ae45b9e commit 6e66cd6

File tree

5 files changed

+7
-29
lines changed

5 files changed

+7
-29
lines changed

compiler/src/dotty/tools/dotc/core/NameKinds.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ object NameKinds {
9292
class PrefixNameKind(tag: Int, prefix: String, optInfoString: String = "")
9393
extends ClassifiedNameKind(tag, if (optInfoString.isEmpty) s"Prefix $prefix" else optInfoString) {
9494
def mkString(underlying: TermName, info: ThisInfo) =
95-
underlying.qualToString(_.toString, n => prefix + n.toString)
95+
underlying.qualToString(_.mangledString, n => prefix + n.mangled.toString)
9696
override def unmangle(name: SimpleName): TermName =
9797
if (name.startsWith(prefix)) apply(name.drop(prefix.length).asSimpleName)
9898
else name
@@ -102,7 +102,7 @@ object NameKinds {
102102
class SuffixNameKind(tag: Int, suffix: String, optInfoString: String = "")
103103
extends ClassifiedNameKind(tag, if (optInfoString.isEmpty) s"Suffix $suffix" else optInfoString) {
104104
def mkString(underlying: TermName, info: ThisInfo) =
105-
underlying.qualToString(_.toString, n => n.toString + suffix)
105+
underlying.qualToString(_.mangledString, n => n.mangled.toString + suffix)
106106
override def unmangle(name: SimpleName): TermName =
107107
if (name.endsWith(suffix)) apply(name.take(name.length - suffix.length).asSimpleName)
108108
else name

compiler/src/dotty/tools/dotc/util/NameTransformer.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ object NameTransformer {
4141
enterOp('?', "$qmark")
4242
enterOp('@', "$at")
4343

44-
45-
/* Encode characters that are illegal */
46-
def encodeSting(value: String): String = {
47-
val builder = new java.lang.StringBuilder
48-
value.foreach{ chr =>
49-
lazy val t = op2code(chr)
50-
if(chr < nops && t != null) builder.append(t) else builder.append(chr)
51-
}
52-
builder.toString
53-
}
54-
55-
5644
/** Expand characters that are illegal as JVM method names by `$u`, followed
5745
* by the character's unicode expansion.
5846
*/

compiler/test/dotty/tools/dotc/reporting/TestReporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ object TestReporter {
8686
private[this] def initLog() = if (logWriter eq null) {
8787
val date = new Date
8888
val df0 = new SimpleDateFormat("yyyy-MM-dd")
89-
val df1 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss")
89+
val df1 = new SimpleDateFormat("yyyy-MM-dd'T'HHmmss")
9090
val folder = s"../testlogs/tests-${df0.format(date)}"
9191
new JFile(folder).mkdirs()
9292
outFile = new JFile(s"$folder/tests-${df1.format(date)}.log")

doc-tool/src/dotty/tools/dottydoc/model/factories.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object factories {
3131

3232
def path(sym: Symbol)(implicit ctx: Context): List[String] = sym match {
3333
case sym if sym.name.decode.toString == "<root>" => Nil
34-
case sym => path(sym.owner) :+ sym.name.show
34+
case sym => path(sym.owner) :+ sym.name.mangledString
3535
}
3636

3737
def annotations(sym: Symbol)(implicit ctx: Context): List[String] =

doc-tool/src/dotty/tools/dottydoc/staticsite/Site.scala

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package staticsite
55
import java.nio.file.{FileSystems, Files}
66
import java.nio.file.StandardCopyOption.REPLACE_EXISTING
77
import java.io.{BufferedWriter, ByteArrayInputStream, OutputStreamWriter, File => JFile}
8-
import java.util.{Arrays, List => JList, Map => JMap}
8+
import java.util.{Arrays, List => JList}
99
import java.nio.file.Path
1010
import java.nio.charset.StandardCharsets
1111

@@ -20,7 +20,7 @@ import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension
2020
import com.vladsch.flexmark.ext.front.matter.YamlFrontMatterExtension
2121
import com.vladsch.flexmark.util.options.{DataHolder, MutableDataSet}
2222
import dotc.core.Contexts.Context
23-
import dotc.util.{NameTransformer, SourceFile}
23+
import dotc.util.SourceFile
2424
import model.Package
2525

2626
import scala.io.{Codec, Source}
@@ -193,24 +193,14 @@ case class Site(
193193
def generateApiDocs(outDir: JFile = new JFile(root.getAbsolutePath + "/_site"))(implicit ctx: Context): this.type =
194194
createOutput(outDir) {
195195
def genDoc(e: model.Entity): Unit = {
196-
197196
ctx.docbase.echo(s"Generating doc page for: ${e.path.mkString(".")}")
198197
// Suffix is index.html for packages and therefore the additional depth
199198
// is increased by 1
200199
val (suffix, offset) =
201200
if (e.kind == "package") ("/index.html", -1)
202201
else (".html", 0)
203202

204-
// Mangle last path element
205-
def genPath(path: List[String]): String = {
206-
def loop(path: List[String], acc: String): String = path match {
207-
case h :: Nil => s"$acc/${NameTransformer.encodeSting(h)}"
208-
case h :: t => loop(t, s"$acc/$h")
209-
}
210-
loop(path, "")
211-
}
212-
213-
val target: Path = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + genPath(e.path) + suffix))
203+
val target: Path = mkdirs(fs.getPath(outDir.getAbsolutePath + "/api/" + e.path.mkString("/") + suffix))
214204
val params = defaultParams(target.toFile, -1).withPosts(blogInfo).withEntity(e).toMap
215205
val page = new HtmlPage("_layouts/api-page.html", layouts("api-page").content, params, includes)
216206

0 commit comments

Comments
 (0)