Aladdin - Scala Bugtracking
[#535] project: compiler priority: high category: bug
submitter assigned to status date submitted
Sean _ not repro 2006-02-22 18:02:49.0
subject resident compiler still broken?
code
// DocGenerator.scala:
package scala.tools.nsc.doc;

import scala.tools.nsc._;
import java.io.File;
import scala.tools.nsc.models._;
import scala.collection.immutable._;
import scala.xml._;
  
abstract class DocGenerator extends Models {
  import global._;
  
  def dquote(str : String) = Text("\"" + str + "\"");
  val header = <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
               <meta name="generator" content="scaladoc (1.4.0.4)"/>
               <link rel="stylesheet" type="text/css" href="style.css"/>
               <script type="text/javascript" src="script.js"></script>;
  
  val emptyMap = ListMap.Empty[Kind,TreeSet[HasTree]];
  def process(units : Iterator[CompilationUnit], outdir : String) : Unit = {
    val outdir0 = new File(outdir);
    if (!outdir0.exists()) outdir0.mkdir();
    var members = emptyMap;
    var topLevel = ListMap.Empty[ModuleSymbol,ListMap[Kind,TreeSet[HasTree]]];
    for (val unit <- units) {
      val sourceMod = new SourceMod(unit);
      for (val mmbr <- sourceMod.members) mmbr.tree match {
      case cdef:  ImplDef => 
        assert(cdef.symbol.owner != NoSymbol);
        val sym = cdef.symbol.owner.asInstanceOf[ModuleSymbol];
        if (!topLevel.contains(sym)) topLevel = topLevel.update(sym, emptyMap);
        topLevel = topLevel.update(sym, organize0(mmbr, topLevel(sym))); 
      case _ => throw new Error("unknown: " + mmbr.tree + " " + mmbr.tree.getClass());
      }
    }
    var packages = new TreeMap[String,ModuleSymbol];
    for (val top <- topLevel.elements) 
      packages = packages.insert(nameFor(top._1), top._1);
    
    
    val packageFrame = <HTML>
      <HEAD><TITLE>List of modules</TITLE>
            {header}
      </HEAD>
      <body>
      <div class="doctitle-larger">
        Scala<br/>1.4.0.4
      </div>
      <a href="module-page.html" target="classesFrame">All objects and classes</a><p/>
      <b>Modules</b>
      <table class="list">
      <tr>
      <td style="white-space:nowrap;">
      { {
       for (val top <- packages.elements) {
         val sym = top._2;
       } 
      } }
      </td></tr></table></body></HTML>;
    
   
    
      
      // output HTML for each package. 
      for (val top <- topLevel.elements) {
        val sym = top._1;
        val members = top._2;
        val index = <HTML>{ {
          process(members, sym);
        } }</HTML>;
        
        
        System.out.println("SAVE-TO: " + sym);
        System.out.println(index);
        // save...
      }
      
  }
  
  def nameFor(sym : ModuleSymbol) : String = sym.fullNameString;
  
  def process(members : ListMap[Kind,TreeSet[HasTree]], sym : Symbol) : NodeSeq = {
    for (val kind <- KINDS; members.contains(kind)) yield process(kind, members(kind), sym);
  };

  def organize(c : Composite, map0 : ListMap[Kind,TreeSet[HasTree]]) = {
    var map = map0;
    for (val mmbr <- c.members.toList) map = organize0(mmbr, map);
    map;
  }
  def organize0(mmbr : HasTree, map0 : ListMap[Kind,TreeSet[HasTree]]) = {
    var map = map0;
    if (!map.contains(mmbr.kind))
      map = map.update(mmbr.kind, new TreeSet[HasTree]);
    map = map.update(mmbr.kind, map(mmbr.kind) + mmbr);
    map;    
  }
  
  
  def process(kind : Kind, set : TreeSet[HasTree], sym : Symbol) : Node = {
    val ret = 
    <table cellpadding="3" class="member">
    <tr>
      <td colspan="2" class="title">
      { { labelFor(kind) + " Summary"; } }
      </td>
    </tr>
    { { for (val mmbr <- set.toList) yield process(mmbr, sym); } }
    </table>;
    ret;
  }
  def stringsFor(mods : Modifiers) = {
    var modString : List[String] = Nil;
    if (mods . isPrivate  ) modString = "private"   :: modString;
    if (mods . isProtected) modString = "protected" :: modString;
    if (mods . isOverride ) modString = "override"  :: modString;
    if (mods . isAbstract ) modString = "abstract"  :: modString;
    if (mods . isCase     ) modString = "case"      :: modString;
    if (mods . isSealed   ) modString = "sealed"    :: modString;
    if (mods . isFinal    ) modString = "final"    :: modString;
    if (mods . isMixin    ) modString = "mixin"    :: modString;
    modString;
  }
  
  
  def targetFor(ht : HasTree) : String = {
    // compute a URL.
    "Foo";
  }
  def forSymbol(symbol : Symbol, tpe : Type) : NodeSeq =
    Text(symbol.nameString);
  
  
  def ifT (cond : Boolean, nodes : NodeSeq) = if (cond) nodes else NodeSeq.Empty;
  def ifT (tree : Tree, nodes : NodeSeq, before : Boolean) =
    if (tree != EmptyTree) {
      if (before) nodes.concat(forTree(tree));
      else forTree(tree).concat(nodes);
    } else NodeSeq.Empty;
  
  def forTree(tree : Tree) : NodeSeq = tree match {
    case vdef : ValDef => 
      Text(vdef.symbol.name.toString()).concat(Text(" : ")).concat(forTree(vdef.tpt));
    case id  : Ident  => forSymbol(id.symbol, id.tpe);
    case sel : Select => forTree(sel.qualifier).concat(forSymbol(sel.symbol, sel.tpe));
    case tree : AbsTypeDef => 
      ifT(tree.lo, Text(" <: "), true).
        concat(forSymbol(tree.symbol, tree.tpe)).concat(ifT(tree.hi, Text(" <: "), false));
    case EmptyTree => NodeSeq.Empty;    
    case _ => Text("XX=" + tree.toString());
  }
  def forTrees(trees : List[Tree]) : NodeSeq = {
    if (trees.isEmpty) NodeSeq.Empty;
    else {
      val head = forTree(trees.head);
      head.concat(if (trees.tail.isEmpty) NodeSeq.Empty else Text(", ")).concat(forTrees(trees.tail));
    }
  }
  
  def surround(open : String, close : String, node : NodeSeq) : NodeSeq = 
    Text(open).concat(node).concat(Text(close));
  
  def typesFor(ht : HasTree) : NodeSeq = {
    val tparams = ht.tree match {
      case cdef : ClassDef => cdef.tparams;
      case ddef : DefDef   => ddef.tparams;
      case adef : AliasTypeDef => adef.tparams;
      case _ => Nil;
    }
    if (tparams.isEmpty) Text("");
    else surround("[", "]", forTrees(tparams));
  }
  def  argsFor(ht : HasTree) : NodeSeq = ht.tree match {
    case ddef : DefDef =>
      val nodes = for (val vparams <- ddef.vparamss) 
        yield surround("(", ")", forTrees(vparams));
      nodes.flatMap(x => x.asList);
    case _ => NodeSeq.Empty;
  }
  def urlFor(ht : HasTree) : String =
    "\"unknown\"";
  
  def  nameFor(ht : HasTree) : NodeSeq =
    <A href={ urlFor(ht) } target="_self"> { forSymbol(ht.tree.symbol, null) } </A>;

  def resultFor(ht : HasTree) : NodeSeq = ht.tree match {
    case vdef : ValOrDefDef =>
      Text(" : ").concat(forTree(vdef.tpt));
    case cdef : ImplDef =>
      if (cdef.impl.parents.isEmpty) NodeSeq.Empty;
      else Text("extends ").concat(forTrees(cdef.impl.parents));
    case _ => NodeSeq.Empty;
  } 
  
  def comment(comment : String, isShort : Boolean) : NodeSeq = {
    var ret : List[Node] = Nil;
    if (comment != null) {
      // strip out any stars.
      var comment0 = comment.trim();
      assert(comment0.startsWith(JDOC_START));
      comment0 = comment0.substring(JDOC_START.length());
      assert(comment0.endsWith(JDOC_END));
      comment0 = comment0.substring(0, comment0.length() - JDOC_END.length());
      var idx = 0;
      while (idx != -1) {
        idx = comment0.indexOf('*', idx);
        if (idx != -1) 
          comment0 = comment0.substring(0, idx) +
            comment0.substring(idx + 1, comment0.length());
      }
      val tokenizer = new java.util.StringTokenizer(comment0, "@");
      val body = tokenizer.nextToken();

      var attributes : List[String] = Nil;
      if (!isShort) while (tokenizer.hasMoreElements()) 
        attributes = attributes ::: (tokenizer.nextToken() :: Nil);
      val node = <BR> { Text(comment) } </BR>;
      val nodes = { { for (val a <- attributes) yield <BR> { Text(a) } </BR>; } };
      val nodes0 : NodeSeq = node :: nodes;
      nodes0;
    } else NodeSeq.Empty;
  };
  
  
  def process(ht : HasTree, sym : Symbol) : scala.xml.Node = {
    val comment0 = if (comments.contains(ht.tree.symbol)) 
      comments(ht.tree.symbol) else null;

    
    val index =     
    <tr>
      <td valign="top" class="modifiers">
        &nbsp;
        <code>{ {
          (for (val mod <- stringsFor(ht.mods)) yield Text(mod + " "));
        } }</code>
      </td>
      <td class="signature">
        <code>
        { labelFor(ht.kind).toLowerCase() }
        { nameFor(ht) }
        { typesFor(ht) }
        {  argsFor(ht) }
        {resultFor(ht) }
        </code>
        { comment(comment0, true) }
      </td>
    </tr>;
  
    val body = <X></X>;
    
    
    
    
  
  
    index;
  }
  
  
/*
  val index0 = <HTML>
  <HEAD><TITLE>API Documentation</TITLE></HEAD>
  <FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()">
  <FRAMESET rows="30%,70%" title="" onLoad="top.loadFrames()">
  <FRAME src="overview-frame.html" name="packageListFrame" title="All Packages">
  <FRAME src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
  </FRAMESET>
  <FRAME src="overview-summary.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes">
  </FRAMESET>
  </HTML>;
*/
 
  def index = { 
    val index0 = <HTML></HTML>;
  }

  private val JDOC_START = "/**";
  private val JDOC_END   = "*/";
}
what happened
On rebuild all, then rebuild DocGenerator.scala:

scala.tools.nsc.symtab.Types$MalformedType: malformed type: scala.tools.nsc.models#subscriber
at scala.tools.nsc.symtab.Types$adaptToNewRunMap$.adaptToNewRun(Types.scala:1356)
at scala.tools.nsc.symtab.Types$adaptToNewRunMap$.adaptToNewRun(Types.scala:1351)
at scala.tools.nsc.symtab.Types$adaptToNewRunMap$.apply(Types.scala:1377)
at scala.tools.nsc.symtab.Types$Type.complete(Types.scala:315)
at scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:342)
at scala.tools.nsc.symtab.Symbols$Symbol.tpe(Symbols.scala:318)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genField(GenJVM.scala:181)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$10.apply(GenJVM.scala:159)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$10.apply(GenJVM.scala:159)
at scala.List.foreach(List.scala:690)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genClass(GenJVM.scala:159)
at scala.tools.nsc.backend.jvm.GenJVM$JvmPhase$$anonfun$0.apply(GenJVM.scala:41)
at scala.tools.nsc.backend.jvm.GenJVM$JvmPhase$$anonfun$0.apply(GenJVM.scala:41)
at scala.Iterator$class.foreach(Iterator.scala:262)
at scala.collection.Map$$anon1.foreach(Map.scala:91)
at scala.tools.nsc.backend.jvm.GenJVM$JvmPhase.run(GenJVM.scala:41)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:421)
at scala.tools.nsc.Global$Run.compile(Global.scala:479)
at ch.epfl.lamp.sdt.build.ScalaCompilerManager$ScalaCompiler.compile(ScalaCompilerManager.java:183)
at ch.epfl.lamp.sdt.build.ScalaProjectBuilder.build(ScalaProjectBuilder.java:76)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:593)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:168)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:202)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:231)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:234)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:303)
at org.eclipse.core.internal.resources.Project.build(Project.java:87)
at org.eclipse.ui.actions.BuildAction.invokeOperation(BuildAction.java:190)
at org.eclipse.ui.actions.WorkspaceAction.execute(WorkspaceAction.java:133)
at org.eclipse.ui.actions.WorkspaceAction$2.runInWorkspace(WorkspaceAction.java:424)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
what expected
[back to overview]
Changes of this bug report
Sean  edited on  2006-02-22 18:15:29.0
My library was probably out of synch again.