From 821551dd7f72b70b786919efcb58c88a236685ce Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 15 Nov 2006 12:46:18 +0000 Subject: improved output of inherited members in DocGene... improved output of inherited members in DocGenerator --- .../scala/tools/nsc/doc/DocGenerator.scala | 59 ++++++++++------------ src/compiler/scala/tools/nsc/models/Models.scala | 8 +-- .../scala/collection/immutable/ListMap.scala | 38 ++++++++------ src/library/scala/collection/mutable/BitSet.scala | 22 +++++--- 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index b3238cd619..cdf5bc218a 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -151,15 +151,15 @@ abstract class DocGenerator extends Models { }) } - private val pat = Pattern.compile( + private val patVal = Pattern.compile( "scala\\.(Byte|Boolean|Char|Double|Float|Int|Long|Short)") def docName(sym: Symbol): String = { def javaParams(paramTypes: List[Type]): String = { def javaName(pt: Type): String = { val s = pt.toString - val mat = pat.matcher(s) - if (mat.matches) mat.group(1).toLowerCase + val matVal = patVal.matcher(s) + if (matVal.matches) matVal.group(1).toLowerCase else s.replaceAll("\\$", ".") } paramTypes.map(pt => javaName(pt)).mkString("(", ",", ")") @@ -385,7 +385,6 @@ abstract class DocGenerator extends Models { case cmod: ImplMod => { listMembersShort(mmbr) } - { listMembersFull(mmbr) } case _ => @@ -424,13 +423,13 @@ abstract class DocGenerator extends Models { */ def listInheritedMembers(sym: Symbol, kind: Kind): NodeSeq = { val ignored = List(definitions.ObjectClass, definitions.ScalaObjectClass) - def hasKind(sym: Symbol) = - (kind == DEF && sym.isMethod && !sym.isConstructor) - (kind == VAR && sym.isVariable) - (kind == VAL && sym.isValue && !sym.isVariable) + def isVisible(sym: Symbol) = + (kind == DEF && sym.isMethod && !sym.isConstructor && !sym.hasFlag(Flags.ACCESSOR)) || + (kind == VAR && sym.isVariable) || + (kind == VAL && sym.isValue && !sym.isVariable && sym.hasGetter) val parents = sym.info.parents for (val p <- parents; !ignored.contains(p.symbol); - val decls = p.decls.toList filter(member => hasKind(member)); + val decls = p.decls.toList filter(member => isVisible(member)); !decls.isEmpty) yield Group( @@ -438,30 +437,24 @@ abstract class DocGenerator extends Models { {Text(kind.toString + " inherited from ").concat(urlFor(p, contentFrame))} - - { { - //val decls = p.decls.toList filter(member => hasKind(member)) - //if (decls.isEmpty) NodeSeq.Empty // scope empty - /*else*/ { - def aref1(sym: Symbol): NodeSeq = { - val isJava = sym hasFlag Flags.JAVA - if (isJava || (sym.sourceFile eq null)) { - {sym.nameString} - } - else - aref(urlFor(sym), contentFrame, sym.nameString) + { + def aref1(sym: Symbol): NodeSeq = { + val isJava = sym hasFlag Flags.JAVA + if (isJava || (sym.sourceFile eq null)) { + {sym.nameString} } - val members = decls.sort( - (x, y) => (x.nameString compareTo y.nameString) < 0) - + else + aref(urlFor(sym), contentFrame, sym.nameString) } - } } - + val members = decls.sort( + (x, y) => (x.nameString compareTo y.nameString) < 0) + + }
- {aref1(members.head)} - {for (val m <- members.tail) yield Text(", ").concat(aref1(m))} -
+ {aref1(members.head)} + {for (val m <- members.tail) yield Text(", ").concat(aref1(m))} +
) } @@ -502,7 +495,7 @@ abstract class DocGenerator extends Models { def shortHeader(mmbr: HasTree): NodeSeq = - { { for (val str <- stringsFor(mmbr.mods)) yield {(Text(str + " "))}; } } + { for (val str <- stringsFor(mmbr.mods)) yield {(Text(str + " "))} } {Text(codeFor(mmbr.kind))} @@ -743,7 +736,7 @@ abstract class DocGenerator extends Models { val tables = for (val k <- kinds.keys.toList) yield Pair(k, decls filter kinds(k)) for (val Pair(k, members) <- tables; !members.isEmpty) yield - +
diff --git a/src/compiler/scala/tools/nsc/models/Models.scala b/src/compiler/scala/tools/nsc/models/Models.scala index 9a9284d321..a353ba83ec 100644 --- a/src/compiler/scala/tools/nsc/models/Models.scala +++ b/src/compiler/scala/tools/nsc/models/Models.scala @@ -52,12 +52,12 @@ abstract class Models { modString } - def codeFor(kind: Kind) : String = kind match { + def codeFor(kind: Kind): String = kind match { case CONSTRUCTOR => codeFor(DEF) case _ => labelFor(kind).toLowerCase() } - def pluralFor(kind: Kind) : String = kind match { + def pluralFor(kind: Kind): String = kind match { case CLASS => "Classes" case _ => labelFor(kind) + "s" } @@ -313,8 +313,8 @@ abstract class Models { assert(sym0.isGetter); val sym = sym0.accessed val ret = if (sym == NoSymbol) { - val sym = analyzer.underlying(sym0); - //val name = nme.getterToSetter(sym0.name) + val sym = analyzer.underlying(sym0) + //val name = nme.getterToSetter(sym0.name) //val setter = sym0.owner.info.decl(name); val isVar = sym.isVariable; val mods = (ddef.mods | diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala index 6979c973c5..d7e2df5329 100644 --- a/src/library/scala/collection/immutable/ListMap.scala +++ b/src/library/scala/collection/immutable/ListMap.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -12,8 +12,6 @@ package scala.collection.immutable -//import Predef.NoSuchElementException - object ListMap { def Empty[A, B] = new ListMap[A, B] } @@ -29,22 +27,22 @@ object ListMap { [serializable] class ListMap[A, B] extends AnyRef with Map[A, B] { - /** This method returns a new ListMap instance mapping keys of the + /** Returns a new ListMap instance mapping keys of the * same type to values of type C. */ def empty[C] = ListMap.Empty[A, C] /** Returns the number of mappings in this map. * - * @return number of mappings. + * @return number of mappings in this map. */ def size: Int = 0 - /** Check if this map maps key to a value and return the + /** Checks if this map maps key to a value and return the * value if it exists. * - * @param key the key of the mapping of interest - * @return the value of the mapping, if it exists + * @param key the key of the mapping of interest + * @return the value of the mapping, if it exists */ def get(key: A): Option[B] = None @@ -53,16 +51,21 @@ class ListMap[A, B] extends AnyRef with Map[A, B] { * to value. If the map contains already a * mapping for key, it will be overridden by this * function. + * + * @param key the key element of the updated entry. + * @param value the value element of the updated entry. */ def update(key: A, value: B): ListMap[A, B] = new Node(key, value) /** This creates a new mapping without the given key. * If the map does not contain a mapping for the given key, the * method returns the same map. + * + * @param key a map without a mapping for the given key. */ def -(key: A): ListMap[A, B] = this - /** This returns an iterator over key-value pairs. + /** Returns an iterator over key-value pairs. */ def elements: Iterator[Pair[A,B]] = new Iterator[Pair[A,B]] { var that: ListMap[A,B] = ListMap.this; @@ -110,20 +113,20 @@ class ListMap[A, B] extends AnyRef with Map[A, B] { */ override def isEmpty: Boolean = false - /** Retrieve the value which is associated with the given key. This + /** Retrieves the value which is associated with the given key. This * method throws an exception if there is no mapping from the given * key to a value. * - * @param key the key - * @return the value associated with the given key. + * @param key the key + * @return the value associated with the given key. */ override def apply(k: A): B = if (k == key) value else ListMap.this(k) - /** Check if this map maps key to a value and return the + /** Checks if this map maps key to a value and return the * value if it exists. * - * @param key the key of the mapping of interest - * @return the value of the mapping, if it exists + * @param key the key of the mapping of interest + * @return the value of the mapping, if it exists */ override def get(k: A): Option[B] = if (k == key) Some(value) else ListMap.this.get(k) @@ -144,9 +147,12 @@ class ListMap[A, B] extends AnyRef with Map[A, B] { val tail = ListMap.this.update(k,v); new tail.Node(key, value) } - /** This creates a new mapping without the given key. + /** Creates a new mapping without the given key. * If the map does not contain a mapping for the given key, the * method returns the same map. + * + * @param k ... + * @return ... */ override def -(k: A): ListMap[A, B] = if (k == key) diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala index 7a518cfc0d..02e876ba80 100644 --- a/src/library/scala/collection/mutable/BitSet.scala +++ b/src/library/scala/collection/mutable/BitSet.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -13,7 +13,7 @@ package scala.collection.mutable /** - * This class implements mutable, resizable Bit sets + * The class BitSet implements mutable, resizable Bit sets * * @author Burak Emir, Nikolay Mihaylov * @version 1.1 @@ -26,10 +26,13 @@ class BitSet(initSize: Int) extends collection.BitSet with Set[Int] { import compat.Platform.arraycopy - /** default constructor, initial size of 512 bits */ - def this() = this(0); + /** default constructor, initial size of 512 bits. */ + def this() = this(0) - /** ensure that this bitset can store at least
n
bits */ + /** Ensures that this bitset can store at least n bits. + * + * @param n ... + */ def ensureCapacity(n: Int): Unit = if (capacity < n) { if (nbits(arr.length) < n) { @@ -45,7 +48,7 @@ class BitSet(initSize: Int) extends collection.BitSet with Set[Int] { } /** - * Sets ith bit to true. + * Sets i-th bit to true. * No restriction on i */ def +=(i: Int): Unit = { @@ -58,7 +61,10 @@ class BitSet(initSize: Int) extends collection.BitSet with Set[Int] { } } - /** Clears ith bit */ + /** Clears the i-th bit. + * + * @param i the i-th element of the bit set. + */ def -=(i: Int): Unit = { if (i >= capacity) return; val oldInt = arr(offset(i)) @@ -69,6 +75,8 @@ class BitSet(initSize: Int) extends collection.BitSet with Set[Int] { } } + /** Clears all bits of the set. + */ def clear: Unit = { java.util.Arrays.fill(arr, 0) size = 0 -- cgit v1.2.3
{k} Summary