From 701b17de262adca8f2787f3230b158cffa332254 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 8 Jan 2011 09:16:30 +0000 Subject: Applying some short-term balm to scaladoc since... Applying some short-term balm to scaladoc since it got all loopy after that last patch. No review. --- src/compiler/scala/tools/nsc/ast/DocComments.scala | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/compiler/scala/tools/nsc/ast/DocComments.scala') diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index afaa1dbd7b..2dcaeee747 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -38,6 +38,15 @@ trait DocComments { self: SymbolTable => def docCommentPos(sym: Symbol): Position = getDocComment(sym) map (_.pos) getOrElse NoPosition + /** A version which doesn't consider self types, as a temporary measure: + * an infinite loop has broken out between superComment and cookedDocComment + * since r23926. + */ + private def allInheritedOverriddenSymbols(sym: Symbol): List[Symbol] = { + if (!sym.owner.isClass) Nil + else sym.owner.ancestors map (sym overriddenSymbol _) filter (_ != NoSymbol) + } + /** The raw doc comment of symbol `sym`, minus @usecase and @define sections, augmented by * missing sections of an inherited doc comment. * If a symbol does not have a doc comment but some overridden version of it does, @@ -121,23 +130,15 @@ trait DocComments { self: SymbolTable => (str /: wikiReplacements) { (str1, regexRepl) => regexRepl._1 replaceAllIn(str1, regexRepl._2) } - private def getDocComment(sym: Symbol): Option[DocComment] = docComments get sym match { - case None => mapFind(sym.allOverriddenSymbols)(docComments get) - case some => some - } + private def getDocComment(sym: Symbol): Option[DocComment] = + mapFind(sym :: allInheritedOverriddenSymbols(sym))(docComments get _) /** The cooked doc comment of an overridden symbol */ protected def superComment(sym: Symbol): Option[String] = - sym.allOverriddenSymbols.view map { cookedDocComment(_) } find ("" !=) + allInheritedOverriddenSymbols(sym).iterator map (x => cookedDocComment(x)) find (_ != "") - private def mapFind[A, B](xs: Iterable[A])(f: A => Option[B]): Option[B] = { - var res: Option[B] = None - val it = xs.iterator - while (res.isEmpty && it.hasNext) { - res = f(it.next()) - } - res - } + private def mapFind[A, B](xs: Iterable[A])(f: A => Option[B]): Option[B] = + xs collectFirst f.unlift private def isMovable(str: String, sec: (Int, Int)): Boolean = startsWithTag(str, sec, "@param") || -- cgit v1.2.3