From b10ba655d5a3c127ffc4332ebb1e7198da3f9294 Mon Sep 17 00:00:00 2001 From: Gilles Dubochet Date: Mon, 8 Nov 2010 12:59:15 +0000 Subject: [scaladoc] Fixes build. No review. --- .../scala/tools/nsc/doc/model/TreeEntity.scala | 2 +- .../scala/tools/nsc/doc/model/TreeFactory.scala | 127 ++++++++++++--------- 2 files changed, 71 insertions(+), 58 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala b/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala index 425a735a3a..98407ff58a 100644 --- a/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala +++ b/src/compiler/scala/tools/nsc/doc/model/TreeEntity.scala @@ -11,6 +11,6 @@ import scala.collection.immutable.TreeMap class TreeEntity { - var expression:String = "" + var expression:String = "?" var refs = new TreeMap[Int, (Entity, Int)] // start, (Entity to be linked to , end) } diff --git a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala index 6a5c8f6e8d..63a1510ddc 100755 --- a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala @@ -13,77 +13,90 @@ package model trait TreeFactory { thisTreeFactory: ModelFactory with TreeFactory => - val global:Global + val global: Global import global._ - def makeTree(rhs:Tree):TreeEntity = { - val printSteps:Boolean = false + def makeTree(rhs: Tree): TreeEntity = { + + val printSteps: Boolean = false val tree = new TreeEntity - val firstIndex = rhs.pos.startOrPoint - /** Gets the full string of the right hand side of a parameter, without links */ - def makeExpression(rhs:Tree){ - val start = rhs.pos.startOrPoint - val end = rhs.pos.endOrPoint - var expr = "" - for (i <- start until end) expr += rhs.pos.source.content.apply(i) - rhs match { - case Block(r,s) => expr += "}" - case _ => + try { + + val firstIndex = rhs.pos.startOrPoint + + /** Gets the full string of the right hand side of a parameter, without links */ + def makeExpression(rhs: Tree){ + val start = rhs.pos.startOrPoint + val end = rhs.pos.endOrPoint + var expr = "" + for (i <- start until end) expr += rhs.pos.source.content.apply(i) + rhs match { + case Block(r,s) => expr += "}" + case _ => + } + tree.expression += expr } - tree.expression += expr - } - val traverser = new Traverser{ - /** Finds the Entity on which we will later create a link on, - * stores it in tree.refs with its position - */ - def makeLink(rhs:Tree){ - var start = rhs.pos.point - firstIndex - val end = rhs.pos.endOrPoint - firstIndex - if(start != end) { - var asym = rhs.symbol - if (asym.isClass) makeTemplate(asym) match{ - case docTmpl: DocTemplateImpl => - tree.refs += ((start,(docTmpl,end))) - case _ => - } - else if (asym.isTerm && asym.owner.isClass){ - if (asym.isSetter) asym = asym.getter(asym.owner) - makeTemplate(asym.owner) match { - case docTmpl:DocTemplateImpl => - val mbrs:List[MemberImpl] = makeMember(asym,docTmpl) - mbrs foreach {mbr => - tree.refs += ((start,(mbr,end))) - } + val traverser = new Traverser { + + /** Finds the Entity on which we will later create a link on, + * stores it in tree.refs with its position + */ + def makeLink(rhs: Tree){ + var start = rhs.pos.point - firstIndex + val end = rhs.pos.endOrPoint - firstIndex + if(start != end) { + var asym = rhs.symbol + if (asym.isClass) makeTemplate(asym) match{ + case docTmpl: DocTemplateImpl => + tree.refs += ((start,(docTmpl,end))) case _ => } + else if (asym.isTerm && asym.owner.isClass){ + if (asym.isSetter) asym = asym.getter(asym.owner) + makeTemplate(asym.owner) match { + case docTmpl: DocTemplateImpl => + val mbrs: List[MemberImpl] = makeMember(asym,docTmpl) + mbrs foreach {mbr => + tree.refs += ((start,(mbr,end))) + } + case _ => + } + } } } + /** + * Goes through the tree and makes links when a Select occurs, + * The case of New(_) is ignored because the object we want to create a link on + * will be reached with recursivity and we don't want a link on the "new" string + * If a link is not created, its case is probably not defined in here + */ + override def traverse(tree: Tree) = tree match { + case Select(qualifier, name) => + qualifier match { + case New(_) => + case _ => makeLink(tree) + } + traverse(qualifier) + case Ident(_) => makeLink(tree) + case _ => + super.traverse(tree) + } + } - /** - * Goes through the tree and makes links when a Select occurs, - * The case of New(_) is ignored because the object we want to create a link on - * will be reached with recursivity and we don't want a link on the "new" string - * If a link is not created, its case is probably not defined in here - */ - override def traverse(tree:Tree) = tree match { - case Select(qualifier, name) => - qualifier match { - case New(_) => - case _ => makeLink(tree) - } - traverse(qualifier) - case Ident(_) => makeLink(tree) - case _ => - super.traverse(tree) - } + + makeExpression(rhs) + traverser.traverse(rhs) } + catch { + case e: Throwable => + //println("Bad tree: " + rhs) + } + + tree - makeExpression(rhs) - traverser.traverse(rhs) - return tree } } -- cgit v1.2.3