Skip to content

Commit f021702

Browse files
authored
Merge pull request #4171 from dotty-staging/fix/dottydoc-windows
Fix #3349: Fix dottydoc filenames for Windows
2 parents 87ad61f + 54ccac6 commit f021702

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ object Names {
190190
private[this] var derivedNames: AnyRef /* immutable.Map[NameInfo, DerivedName] | j.u.HashMap */ =
191191
immutable.Map.empty[NameInfo, DerivedName]
192192

193-
private def getDerived(info: NameInfo): DerivedName /* | Null */= derivedNames match {
193+
private def getDerived(info: NameInfo): DerivedName /* | Null */ = derivedNames match {
194194
case derivedNames: immutable.AbstractMap[NameInfo, DerivedName] @unchecked =>
195195
if (derivedNames.contains(info)) derivedNames(info) else null
196196
case derivedNames: HashMap[NameInfo, DerivedName] @unchecked =>

doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import dotc.core.Comments.ContextDocstrings
1111
import dotc.core.Types.{PolyType, NoType}
1212
import dotc.core.Phases.Phase
1313
import dotc.core.Symbols.{ Symbol, NoSymbol }
14+
import dotc.core.NameOps._
1415

1516
class DocASTPhase extends Phase {
1617
import model._
@@ -108,9 +109,8 @@ class DocASTPhase extends Phase {
108109

109110
/** objects, on the format "Object$" so drop the last letter */
110111
case o @ TypeDef(n, rhs) if o.symbol.is(Flags.Module) =>
111-
val name = o.name.show
112112
//TODO: should not `collectMember` from `rhs` - instead: get from symbol, will get inherited members as well
113-
ObjectImpl(o.symbol, annotations(o.symbol), name.dropRight(1), collectMembers(rhs), flags(o), path(o.symbol).init :+ name, superTypes(o))
113+
ObjectImpl(o.symbol, annotations(o.symbol), o.name.stripModuleClassSuffix.show, collectMembers(rhs), flags(o), path(o.symbol), superTypes(o))
114114

115115
/** class / case class */
116116
case c @ TypeDef(n, rhs) if c.symbol.isClass =>

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import dotty.tools.dotc.core.SymDenotations._
1313
import dotty.tools.dotc.config.Printers.dottydoc
1414
import dotty.tools.dotc.core.Names.TypeName
1515
import dotc.ast.Trees._
16+
import dotc.core.StdNames._
17+
18+
import scala.annotation.tailrec
1619

1720

1821
object factories {
@@ -29,9 +32,13 @@ object factories {
2932
.filter(_ != "interface")
3033
.filter(_ != "case")
3134

32-
def path(sym: Symbol)(implicit ctx: Context): List[String] = sym match {
33-
case sym if sym.name.decode.toString == "<root>" => Nil
34-
case sym => path(sym.owner) :+ sym.name.show
35+
def path(sym: Symbol)(implicit ctx: Context): List[String] = {
36+
@tailrec def go(sym: Symbol, acc: List[String]): List[String] =
37+
if (sym.isRoot)
38+
acc
39+
else
40+
go(sym.owner, sym.name.mangledString :: acc)
41+
go(sym, Nil)
3542
}
3643

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

0 commit comments

Comments
 (0)