aboutsummaryrefslogtreecommitdiff
path: root/src/test/showClass.scala
blob: 760932f0ff77feca3b447177941eb6763a0cb986 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package test

import dotty.tools.dotc.core._
import Contexts._
import Symbols._, Flags._, Types._, dotty.tools.dotc.util.Texts._
import Decorators._

object showClass {

  def showPackage(pkg: TermSymbol)(implicit ctx: Context) {
    for (sym <- pkg.info.decls
         if sym.owner == pkg.moduleClass && !(sym.name contains '$')) {
      println(s"showing $sym in ${pkg.fullName}")
      if (sym is Package) showPackage(sym.asTerm)
      else if (sym.isClass) showClass(sym)
      else showClass(sym.moduleClass)
    }
  }

  def showClass(cls: Symbol)(implicit ctx: Context) = {
    println(s"showing ${cls.denot}")
    val cinfo = cls.info
    val infoText: Text = if (cinfo.exists) cinfo.toText else " is missing"
    println("======================================")
    println((cls.toText ~ infoText).show)
  }

  def showClasses(path: String)(implicit ctx: Context): Unit = {
    println(s"showing file $path")
    val cls = ctx.requiredClass(path.toTypeName)
    showClass(cls)
    showClass(cls.linkedClass)
/*
    val info = cls.info
    info match {
      case ClassInfo(pre, c, cps, decls, optSelfType) =>
        println(s"prefix = ${pre.show}")
        println(s"self = ${c.show}")
        println(s"parents = ${cps.map(_.show).mkString(",")}")
        println(s"showClass $path") // !!! DEBUG
        println(s"decls = ${decls.show}")
        println(s"selftype = ${optSelfType.show}")
        println(s"type-params = ${info.typeParams}")
    }
*/
  }

  def main(args: Array[String]) = {
    val base = Context.theBase
    implicit val ctx = base.initialCtx
    println(ctx.settings)
    base.definitions.init()

    for (arg <- args) showPackage(ctx.requiredPackage(arg))

      showClasses("scala.actors.remote.Proxy")
//    showClasses("scala.Boolean")
//    showClasses("scala.Array")
//    showClasses("scala.math.Ordering")
//      showClasses("scala.collection.JavaConversions")
//      showClasses("scala.collection.convert.Wrappers")
//      showClasses("scala.collection.mutable.WeakHashMap")
//      showClasses("scala.collection.GenIterable")
//    showClasses("scala.collection.Traversable")
//    showClasses("scala.collection.LinearSeqLike")
//    showClasses("scala.collection.immutable.List")
//    showClasses("scala.collection.convert.Wrappers")
//    showClasses("scala.collection.generic.package")
//    showClasses("scala.collection.MapLike")
//    showClasses("scala.Function1")
//  showClasses("dotty.tools.dotc.core.Types")
    println("done")
  }
}