Permalink
Browse files

Fix SI-4976 partially

If a package have a package object, generate the package's "linearization"
from the object.
  • Loading branch information...
kzys committed May 3, 2012
1 parent 6300c30 commit 44797916bd4437729e1f13333eee7a2a2cb8ca58
@@ -231,9 +231,10 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
Some(makeType(RefinedType(tps, EmptyScope), inTpl))
}
}
- val linearization: List[(TemplateEntity, TypeEntity)] = {
- sym.ancestors map { ancestor =>
- val typeEntity = makeType(sym.info.baseType(ancestor), this)
+
+ protected def linearizationFromSymbol(symbol: Symbol) = {
+ symbol.ancestors map { ancestor =>
+ val typeEntity = makeType(symbol.info.baseType(ancestor), this)
val tmplEntity = makeTemplate(ancestor) match {
case tmpl: DocTemplateImpl => tmpl registerSubClass this ; tmpl
case tmpl => tmpl
@@ -242,6 +243,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
}
}
+ val linearization = linearizationFromSymbol(sym)
def linearizationTemplates = linearization map { _._1 }
def linearizationTypes = linearization map { _._2 }
@@ -282,6 +284,12 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
abstract class PackageImpl(sym: Symbol, inTpl: => PackageImpl) extends DocTemplateImpl(sym, inTpl) with Package {
override def inTemplate = inTpl
override def toRoot: List[PackageImpl] = this :: inTpl.toRoot
+ override val linearization = {
+ val symbol = sym.info.members.find {
+ s => s.isPackageObject
+ } getOrElse sym
+ linearizationFromSymbol(symbol)
+ }
val packages = members collect { case p: Package => p }
}
@@ -0,0 +1,14 @@
+/** This package have A and B.
+ */
+package test {
+ trait A { def hi = "hello" }
+ trait B { def bye = "bye!" }
+}
+
+/** This package object extends A and B.
+ */
+package object test extends A with B {
+ override def hi = "good morning!"
+ override def bye = "good bye!"
+ protected def thank = "thank you!"
+}
@@ -0,0 +1,2 @@
+List((test.B,B), (test.A,A), (scala.AnyRef,AnyRef), (scala.Any,Any))
+Done.
@@ -0,0 +1,15 @@
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+import language._
+
+object Test extends ScaladocModelTest {
+ override def resourceFile = "package-object-res.scala"
+ override def scaladocSettings = ""
+ def testModel(root: Package) = {
+ import access._
+
+ val p = root._package("test")
+ println(p.linearization)
+ }
+}
+

0 comments on commit 4479791

Please sign in to comment.