diff options
-rw-r--r-- | config/list/scaladoc.lst | 4 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/Comment.java | 5 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/HTMLGenerator.java | 281 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/OneTree.java | 245 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/ScalaSearch.java | 391 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/StandardDocModule.java | 5 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/SymbolTablePrinter.java | 6 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/SymbolTablePrinterFactory.java | 26 | ||||
-rw-r--r-- | sources/scala/tools/scaladoc/TreeSymbols.java | 85 |
9 files changed, 327 insertions, 721 deletions
diff --git a/config/list/scaladoc.lst b/config/list/scaladoc.lst index 353cf762ef..ad859428b2 100644 --- a/config/list/scaladoc.lst +++ b/config/list/scaladoc.lst @@ -10,14 +10,12 @@ HTMLGeneratorCommand.java HTMLGeneratorPhase.java HTMLGeneratorPhases.java Main.scala -OneTree.java ScalaSearch.java StandardDocModule.java -SymbolTablePrinter.java Tag.java Location.java -TreeSymbols.java Page.java +SymbolTablePrinter.java SymbolTablePrinterFactory.java ############################################################################## diff --git a/sources/scala/tools/scaladoc/Comment.java b/sources/scala/tools/scaladoc/Comment.java index c9fd675c89..85eaf739ce 100644 --- a/sources/scala/tools/scaladoc/Comment.java +++ b/sources/scala/tools/scaladoc/Comment.java @@ -10,14 +10,9 @@ package scala.tools.scaladoc; import java.util.*; import java.util.regex.*; - import ch.epfl.lamp.util.Pair; - -import scalac.ast.Tree; import scalac.symtab.Symbol; -import scaladoc.*; - /** * Class <code>Comment</code> contains all information in comment part. * It allows users to get first sentence of this comment, get comment diff --git a/sources/scala/tools/scaladoc/HTMLGenerator.java b/sources/scala/tools/scaladoc/HTMLGenerator.java index 04c4cdcaaa..3bff3d34cb 100644 --- a/sources/scala/tools/scaladoc/HTMLGenerator.java +++ b/sources/scala/tools/scaladoc/HTMLGenerator.java @@ -34,10 +34,6 @@ import ch.epfl.lamp.util.Position; import ch.epfl.lamp.util.XHTMLPrinter; import scalac.Global; -import scalac.ast.Tree; -import scalac.ast.Tree.AbsTypeDef; -import scalac.ast.Tree.Template; -import scalac.ast.Tree.ValDef; import scalac.symtab.Kinds; import scalac.symtab.Modifiers; import scalac.symtab.NoSymbol; @@ -46,6 +42,7 @@ import scalac.symtab.Scope.SymbolIterator; import scalac.symtab.Symbol; import scalac.symtab.Type; import scalac.symtab.Type.*; +//import scalac.symtab.SymbolTablePrinter; import scalac.util.Debug; import scalac.util.Name; import scalac.util.Names; @@ -53,7 +50,7 @@ import scalac.util.Strings; /** * The class <code>HTMLGenerator</code> generates - * the HTML documentation for a given Scala tree. + * the HTML documentation for a given Scala library. */ public class HTMLGenerator { @@ -158,10 +155,6 @@ public class HTMLGenerator { return "Generated by " + GENERATOR + " on " + df.format(new Date()); } - /** The unique documented tree. - */ - protected final Tree tree; - /** Global compiler environment. */ protected final Global global; @@ -182,10 +175,6 @@ public class HTMLGenerator { */ public Page page; - /** Symbols defined in the syntactic tree. - */ - protected TreeSymbols treeSymbols; - /** The current URI. */ protected URI uri; @@ -229,17 +218,19 @@ public class HTMLGenerator { public static final String DEFAULT_DOCTITLE = ""; public static final String DEFAULT_WINDOWTITLE = "Generated Documentation"; + /** Root scope. + */ + protected final Symbol root; + /** * Creates a new instance. * - * @param tree * @param global */ - protected HTMLGenerator(Tree tree, Global global) { - this.tree = tree; + protected HTMLGenerator(Global global) { this.global = global; - this.subs = ScalaSearch.subTemplates(tree); - this.treeSymbols = new TreeSymbols(tree); + this.root = global.definitions.ROOT; + this.subs = ScalaSearch.subTemplates(root); this.uri = Location.makeURI("."); assert global.args instanceof HTMLGeneratorCommand; @@ -274,7 +265,7 @@ public class HTMLGenerator { title, representation, stylesheet/*, script*/); // Create a printer to print symbols and types. - symtab = SymbolTablePrinterFactory.makeHTML(page, treeSymbols); + symtab = SymbolTablePrinterFactory.makeHTML(page); page.open(); } @@ -320,7 +311,17 @@ public class HTMLGenerator { createPackageIndexPage(); // class and object pages - createPages(tree); + ScalaSearch.foreach(root, + new ScalaSearch.SymFun() { + public void apply(Symbol sym) { + if (ScalaSearch.isContainer(sym)) { + createPages(sym); + if (sym.isPackage()) + createContainerIndexPage(sym); + } + } + } + ); if (!noindex) { // page with index of Scala documented entities. @@ -329,9 +330,6 @@ public class HTMLGenerator { createHelpPage(); - // page with list of objects and classes. - createContainerIndexPage(tree); - // frame description page createFramePage(); @@ -345,8 +343,8 @@ public class HTMLGenerator { /** * Main function. */ - public static void apply(Tree tree, Global global) { - new HTMLGenerator(tree, global).apply(); + public static void apply(Global global) { + new HTMLGenerator(global).apply(); } /** @@ -364,57 +362,37 @@ public class HTMLGenerator { return comment; } - /** - * Returns members of a class or object definition tree. - * - * @param tree - */ - protected Tree[][] members(Tree tree) { - switch (tree) { - case ClassDef(int mods, Name name, AbsTypeDef[] tparams, ValDef[][] vparams, - Tree tpe, Template impl): - return members(impl.body); - case ModuleDef(int mods, Name name, Tree tpe, Template impl): - return members(impl.body); - default: - throw Debug.abort("illegal tree", tree); - } - } - - private Tree[][] members(Tree[] trees) { + private Symbol[][] splitMembers(Symbol[] syms) { List fields = new LinkedList(); List methods = new LinkedList(); List objects = new LinkedList(); List traits = new LinkedList(); List classes = new LinkedList(); List packages = new LinkedList(); - for (int i = 0; i < trees.length; i++) { - Symbol sym = trees[i].symbol(); - if (sym.isTrait()) traits.add(trees[i]); - else if (sym.isClass()) classes.add(trees[i]); - else if (sym.isPackage()) packages.add(trees[i]); - else if (sym.isModule()) objects.add(trees[i]); - else if (sym.isMethod()) methods.add(trees[i]); - else fields.add(trees[i]); + for (int i = 0; i < syms.length; i++) { + Symbol sym = syms[i]; + if (sym.isTrait()) traits.add(sym); + else if (sym.isClass()) classes.add(sym); + else if (sym.isPackage()) packages.add(sym); + else if (sym.isModule()) objects.add(sym); + else if (sym.isMethod()) methods.add(sym); + else fields.add(sym); } - return new Tree[][] { - (Tree[]) fields.toArray(new Tree[fields.size()]), - (Tree[]) methods.toArray(new Tree[fields.size()]), - (Tree[]) objects.toArray(new Tree[objects.size()]), - (Tree[]) traits.toArray(new Tree[traits.size()]), - (Tree[]) classes.toArray(new Tree[classes.size()]), - (Tree[]) packages.toArray(new Tree[packages.size()]) + return new Symbol[][] { + (Symbol[]) fields.toArray(new Symbol[fields.size()]), + (Symbol[]) methods.toArray(new Symbol[methods.size()]), + (Symbol[]) objects.toArray(new Symbol[objects.size()]), + (Symbol[]) traits.toArray(new Symbol[traits.size()]), + (Symbol[]) classes.toArray(new Symbol[classes.size()]), + (Symbol[]) packages.toArray(new Symbol[packages.size()]) }; } /** * Generates a HTML page for a class or object definition as well * as pages for every inner class or object. - * - * @param tree */ - protected void createPages(Tree tree) { - Symbol sym = tree.symbol(); + protected void createPages(Symbol sym) { String title = Location.getName(sym); createPrinters(Location.getURI(sym), title, SELF_FRAME); page.printHeader(ATTRS_META, getGenerator()); @@ -434,12 +412,12 @@ public class HTMLGenerator { "Trait", "Class", "Package" }; // "Constructor" String[] inherited = new String[]{ "Fields", "Methods", "Objects", "Traits", "Classes", "Packages" }; - Tree[][] members = members(tree); - for (int i = 0; i < titles.length; i++) { - addMemberSummary(members[i], titles[i] + " Summary"); - if (i == 1) addInheritedMembers(sym, inherited[i]); + Symbol[][] members = splitMembers(ScalaSearch.members(sym)); + for (int i = 0; i < members.length; i++) { + addMemberSummary(members[i], titles[i] + " Summary"); + if (i == 1) addInheritedMembers(sym, inherited[i]); } - for (int i = 0; i < titles.length; i++) + for (int i = 0; i < titles.length; i++) addMemberDetail(members[i], titles[i] + " Detail"); page.printlnHLine(); @@ -610,7 +588,7 @@ public class HTMLGenerator { page.printlnCTag("dl"); } } - } + } } /** @@ -633,12 +611,14 @@ public class HTMLGenerator { * @param members * @param title */ - protected void addMemberSummary(Tree[] members, String title) { + protected void addMemberSummary(Symbol[] members, String title) { if (members.length > 0) { - Tree[] sortedMembers = new Tree[members.length]; - for (int i = 0; i < members.length; i++) + Symbol[] sortedMembers = new Symbol[members.length]; + for (int i = 0; i < members.length; i++) { + assert members[i] != null : "HA ENFIN !"; sortedMembers[i] = members[i]; - Arrays.sort(sortedMembers, ScalaSearch.alphaOrder); + } + Arrays.sort(sortedMembers, ScalaSearch.symAlphaOrder); // open table page.printlnOTag("table", ATTRS_MEMBER).indent(); @@ -652,7 +632,7 @@ public class HTMLGenerator { // members for (int i = 0; i < members.length; i++) - addMemberSummary(sortedMembers[i].symbol()); + addMemberSummary(sortedMembers[i]); // close table page.undent(); @@ -667,36 +647,34 @@ public class HTMLGenerator { * @param sym */ protected void addMemberSummary(Symbol sym) { - if (treeSymbols.contains(sym)) { - page.printlnOTag("tr").indent(); + page.printlnOTag("tr").indent(); - // modifiers - String mods = Modifiers.Helper.toString(sym.flags); - page.printlnOTag("td", ATTRS_MODIFIERS).indent(); - if (mods.length() > 0) - page.printlnTag("code", mods); - else - page.printlnNbsp(1); - page.undent(); - page.printlnCTag("td"); + // modifiers + String mods = Modifiers.Helper.toString(sym.flags); + page.printlnOTag("td", ATTRS_MODIFIERS).indent(); + if (mods.length() > 0) + page.printlnTag("code", mods); + else + page.printlnNbsp(1); + page.undent(); + page.printlnCTag("td"); - // signature - page.printlnOTag("td", ATTRS_SIGNATURE).indent(); - page.printOTag("code"); - symtab.defString(sym, true /*addLink*/); - page.printlnCTag("code"); - - // short description - String firstSentence = firstSentence(getComment(sym)); - if (! firstSentence.equals("")) { - page.printlnSTag("br"); - page.printNbsp(4); - page.println(firstSentence); - } - page.undent(); - page.printlnCTag("td").undent(); - page.printlnCTag("tr"); + // signature + page.printlnOTag("td", ATTRS_SIGNATURE).indent(); + page.printOTag("code"); + symtab.defString(sym, true /*addLink*/); + page.printlnCTag("code"); + + // short description + String firstSentence = firstSentence(getComment(sym)); + if (! firstSentence.equals("")) { + page.printlnSTag("br"); + page.printNbsp(4); + page.println(firstSentence); } + page.undent(); + page.printlnCTag("td").undent(); + page.printlnCTag("tr"); } /** @@ -704,16 +682,11 @@ public class HTMLGenerator { * * @param members */ - protected void addMemberDetail(Tree[] members, String title) { + protected void addMemberDetail(Symbol[] members, String title) { boolean first = true; for (int i = 0; i < members.length; i++) { - Symbol sym = members[i].symbol(); - if (sym.isRoot() || sym.isClass() || sym.isModule() || sym.isPackage()) { - createPages(members[i]); - if (sym.isPackage()) - createContainerIndexPage(members[i]); - } - else { + Symbol sym = members[i]; + if (!ScalaSearch.isContainer(sym)) { if (first) { page.printlnOTag("table", ATTRS_MEMBER_DETAIL).indent(); page.printlnOTag("tr").indent(); @@ -735,21 +708,19 @@ public class HTMLGenerator { * @param sym */ protected void addMemberDetail(Symbol sym) { - if (treeSymbols.contains(sym)) { - // title with label - page.printlnAname(Page.asSeenFrom(Location.getURI(sym), uri).getFragment(), ""); - page.printTag("h3", sym.nameString()); - - // signature - page.printlnOTag("pre"); - String mods = Modifiers.Helper.toString(sym.flags); - if (mods.length() > 0) page.print(mods + " "); - symtab.printSignature(sym, false /*addLink*/); - page.printlnCTag("pre"); - - // comment - addComments(getComment(sym)); - } + // title with label + page.printlnAname(Page.asSeenFrom(Location.getURI(sym), uri).getFragment(), ""); + page.printTag("h3", sym.nameString()); + + // signature + page.printlnOTag("pre"); + String mods = Modifiers.Helper.toString(sym.flags); + if (mods.length() > 0) page.print(mods + " "); + symtab.printSignature(sym, false /*addLink*/); + page.printlnCTag("pre"); + + // comment + addComments(getComment(sym)); } /** @@ -933,23 +904,22 @@ public class HTMLGenerator { /** * Writes a table containing a list of packages to the current page. * - * @param trees The package list + * @param syms The package list * @param title The title of the package list */ - private void printPackagesTable(Tree[] trees, String title) { - if (trees.length > 0) { + private void printPackagesTable(Symbol[] syms, String title) { + if (syms.length > 0) { page.printlnBold(title); page.printlnOTag("table", ATTRS_LIST).indent(); page.printlnOTag("tr").indent(); page.printlnOTag("td", new XMLAttribute[] { new XMLAttribute("style", "white-space:nowrap;")}).indent(); - for (int i = 1; i < trees.length; i++) { - Symbol sym = trees[i].symbol(); + for (int i = 1; i < syms.length; i++) { + Symbol sym = syms[i]; page.printAhref( packageSummaryPage(sym), CLASSES_FRAME, removeHtmlSuffix(Location.getURI(sym).toString())); - // sym.fullNameString()); page.printlnSTag("br"); } page.undent(); @@ -961,20 +931,20 @@ public class HTMLGenerator { } /** - * Writes a table containing a list of trees to the current page. + * Writes a table containing a list of symbols to the current page. * - * @param trees + * @param syms * @param title */ - private void addTreeTable(Tree[] trees, String title, boolean useFullName) { - if (trees.length > 0) { + private void addSymbolTable(Symbol[] syms, String title, boolean useFullName) { + if (syms.length > 0) { page.printlnBold(title); page.printlnOTag("table", ATTRS_LIST).indent(); page.printlnOTag("tr").indent(); page.printlnOTag("td", new XMLAttribute[] { new XMLAttribute("style", "white-space:nowrap;")}).indent(); - for (int i = 0; i < trees.length; i++) { - Symbol sym = trees[i].symbol(); + for (int i = 0; i < syms.length; i++) { + Symbol sym = syms[i]; if (! sym.isRoot()) { String name = sym.nameString(); if (sym.isPackage()) @@ -995,7 +965,7 @@ public class HTMLGenerator { } /** - * Creates a page with a list of packages. + * Creates a page with the list of packages. * * @param title */ @@ -1004,7 +974,7 @@ public class HTMLGenerator { page.printHeader(ATTRS_META, getGenerator()); page.printOpenBody(); - Tree[] packages = ScalaSearch.getSortedPackageList(tree); + Symbol[] packages = ScalaSearch.getSortedPackageList(root); addDocumentationTitle(new XMLAttribute[]{ new XMLAttribute("class", "doctitle-larger")}); @@ -1021,10 +991,9 @@ public class HTMLGenerator { /** * Creates a page with a list of classes or objects. * - * @param tree + * @param sym */ - protected void createContainerIndexPage(Tree tree) { - Symbol sym = tree.symbol(); + protected void createContainerIndexPage(Symbol sym) { createPrinters(Location.makeURI(packageSummaryPage(sym)), Location.getName(sym), ROOT_FRAME); page.printHeader(ATTRS_META, getGenerator()); page.printOpenBody(); @@ -1039,15 +1008,15 @@ public class HTMLGenerator { page.printlnSTag("p"); String[] titles = new String[]{ "Objects", "Traits", "Classes" }; - if (sym.isRoot()) { - Tree[][] members = ScalaSearch.getSortedPackageMemberList(tree); - for (int i = 0; i < titles.length; i++) - addTreeTable(members[i], "All " + titles[i], true); - } else { - Tree[][] members = members(tree); - for (int i = 0; i < titles.length; i++) - addTreeTable(members[i + 2], titles[i], false); - } + if (sym.isRoot()) { + Symbol[][] members = ScalaSearch.getSubContainerMembers(root); + for (int i = 0; i < titles.length; i++) + addSymbolTable(members[i], "All " + titles[i], true); + } else { + Symbol[][] members = splitMembers(ScalaSearch.members(sym)); + for (int i = 0; i < titles.length; i++) + addSymbolTable(members[i + 2], titles[i], false); + } if (validate) addValidationBar(); @@ -1079,7 +1048,7 @@ public class HTMLGenerator { page.printlnCTag("table"); page.printlnSTag("br"); - Pair index = ScalaSearch.index(tree); + Pair index = ScalaSearch.index(root); Character[] chars = (Character[]) index.fst; Map map = (Map) index.snd; for (int i = 0; i < chars.length; i++) @@ -1092,12 +1061,12 @@ public class HTMLGenerator { page.printBold(HTMLPrinter.encode(car)); page.printlnCTag("h2"); page.printlnOTag("dl").indent(); - Tree[] trees = (Tree[]) map.get(car); - for (int j = 0; j < trees.length; j++) { + Symbol[] syms = (Symbol[]) map.get(car); + for (int j = 0; j < syms.length; j++) { page.printOTag("dt"); - addIndexEntry(trees[j].symbol()); + addIndexEntry(syms[j]); page.printlnCTag("dt"); - page.printlnTag("dd", firstSentence(getComment(trees[j].symbol()))); + page.printlnTag("dd", firstSentence(getComment(syms[j]))); } page.undent().printlnCTag("dl"); } @@ -1219,7 +1188,7 @@ public class HTMLGenerator { */ protected void printPath(Symbol sym, String destinationFrame) { String name = removeHtmlSuffix(Location.getURI(sym).toString()); - if (treeSymbols.contains(sym)) { + if (ScalaSearch.isDocumented(sym)) { String target = definitionURL(sym); page.printlnAhref(target, destinationFrame, name); } @@ -1309,7 +1278,7 @@ public class HTMLGenerator { System.err.println("Warning: Scaladoc: not found: " + tag); return tag.text; } - else if (!treeSymbols.contains(sym)) { + else if (!ScalaSearch.isDocumented(sym)) { System.err.println("Warning: Scaladoc: not referenced: " + tag); return tag.text; } diff --git a/sources/scala/tools/scaladoc/OneTree.java b/sources/scala/tools/scaladoc/OneTree.java deleted file mode 100644 index 980b190121..0000000000 --- a/sources/scala/tools/scaladoc/OneTree.java +++ /dev/null @@ -1,245 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.scaladoc; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import ch.epfl.lamp.util.Position; - -import scalac.Global; -import scalac.ast.Tree; -import scalac.ast.Tree.*; -import scalac.symtab.Kinds; -import scalac.symtab.Modifiers; -import scalac.symtab.Symbol; -import scalac.symtab.TermSymbol; -import scalac.util.*; - -/** - * This class is used to merge several compilation units into one - * single tree by creating nodes for java packages. It addionally - * removes any node which is not a declaration. - */ -public class OneTree { - - /** - * Global compiler environment. - */ - protected Global global; - - /** - * Root node of the unique tree. - */ - protected Node.PackageNode rootNode; - - /** - * .. - */ - OneTree(Global global) { - super(); - this.global = global; - rootNode = Node.PackageNode(global.definitions.ROOT, new LinkedList()); - } - - /** - * Main function. - */ - public static Tree apply(Global global) { - return new OneTree(global).enterNodes(); - } - - /** - * Returns the symbol in the unique tree corresponding to the given symbol. - * - * @param sym - */ - public static Symbol symbol(Symbol sym) { - if (sym.isRoot()) - return sym.moduleClass(); - else if (sym.isPackage() && (sym.kind == Kinds.CLASS)) - return sym.module(); - else if (sym.isModuleClass()) - return sym.module(); - else return sym; - } - - - /** - * Enters all the nodes in the unique tree. - */ - protected Tree enterNodes() { - for (int i = 0; i < global.units.length; i++) - enter(global.units[i].body); - return rootNode.toTree(global); - } - - /** - * Transforms a Java package symbol into a tree definition. - * - * @param sym - * @param body - * @param global - */ - protected static Tree packageSymbolTree(Symbol sym, Tree[] body, Global global) { - if (sym.isRoot()) - return global.treeGen.ClassDef(sym.moduleClass(), Tree.EMPTY_ARRAY, Symbol.NONE, body); - else { - Template t = global.make.Template(Position.NOPOS, - Tree.EMPTY_ARRAY, - body); - return global.make.ModuleDef(Position.NOPOS, sym.module(), Tree.Empty, t); - } - } - - /** - * Intermediate datastructure representing the unique tree. - */ - protected static class Node { - case PackageNode(Symbol sym, List decls); // package - case TreeNode(Tree tree); // tree (class or object) - - /** Lookups for a child node in a package node. */ - Node.PackageNode lookup(Symbol sym) { - Iterator it = ((Node.PackageNode) this).decls.iterator(); - while (it.hasNext()) { - Node node = (Node) it.next(); - switch(node) { - case PackageNode(Symbol sym1, List decls1): - if (sym == sym1) - return (Node.PackageNode) node; - break; - } - } - return null; - } - - /** Adds a child node to a package node. - */ - void add(Node node) { - ((Node.PackageNode) this).decls.add(node); - } - - /** Transforms a node into a tree. - */ - static Tree[] nodeToTree(Node[] nodes, Global global) { - Tree[] trees = new Tree[nodes.length]; - for(int i = 0; i < nodes.length; i++) - trees[i] = nodes[i].toTree(global); - return trees; - } - Tree toTree(Global global) { - Tree res = null; - switch(this) { - case TreeNode(Tree tree): - res = tree; - break; - case PackageNode(Symbol sym, List decls): - res = packageSymbolTree(sym, - nodeToTree((Node[]) decls.toArray(new Node[decls.size()]), - global), - global); - break; - } - return res; - } - } - - /** - * Returns the node associated with this symbol, creates it if it - * does not exist. - * - * @param sym - */ - protected Node.PackageNode getNode(Symbol sym) { - if (sym.isRoot()) - return rootNode; - else { - Node.PackageNode parent = getNode(sym.owner()); - Node.PackageNode thisnode = parent.lookup(sym); - if (thisnode == null) { - thisnode = Node.PackageNode(sym, new LinkedList()); - parent.add(thisnode); - } - return thisnode; - } - } - - /** - * Enter a global declaration in the unique tree. - * - * @param body - */ - protected void enter(Tree[] body) { - for(int i = 0; i< body.length; i++) - enter(body[i]); - } - protected void enter(Tree tree) { - if (tree instanceof PackageDef) - enter(((PackageDef) tree).impl.body); - else if ((tree instanceof ClassDef || tree instanceof ModuleDef) && - tree.symbol().owner().isPackage()) - //getNode(tree.symbol().owner()).add(Node.TreeNode(tree)); - getNode(tree.symbol().owner()).add(Node.TreeNode(keepDeclarations(tree, new LinkedList()))); - } - - /** Do we keep this symbol ? - */ - protected boolean keep(Tree tree) { - return tree.hasSymbol() && - !tree.symbol().isPrivate() && - !ScalaSearch.isGenerated(tree.symbol()); - } - - /** - * Removes nodes which are not declarations in a tree. - * - * @param tree - * @param ownerDeclList - */ - protected Tree keepDeclarations(Tree tree, List ownerDeclList) { - if (!keep(tree) && !(tree instanceof Template)) - return null; - switch (tree) { - case ClassDef(int mods, Name name, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): - List declList = new LinkedList(); - Template impl1 = (Template) keepDeclarations(impl, declList); - //Tree tree1 = global.make.ClassDef(tree.pos, mods, name, tparams, vparams, tpe, impl1); - Tree tree1 = global.treeGen.ClassDef(tree.symbol(), impl1.parents, TermSymbol.newLocalDummy(tree.symbol()), impl1.body); - ownerDeclList.add(tree1); - return tree1; - case ModuleDef(int mods, Name name, Tree tpe, Template impl): - List declList = new LinkedList(); - Template impl1 = (Template) keepDeclarations(impl, declList); - assert impl1 != null: "Null impl"; - Tree tree1 = global.make.ModuleDef(tree.pos, tree.symbol(), tpe, impl1); - ownerDeclList.add(tree1); - return tree1; - case ValDef(int mods, Name name, Tree tpe, Tree rhs): - ownerDeclList.add(tree); - return tree; - case DefDef(int mods, Name name, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): - ownerDeclList.add(tree); - return tree; - case AbsTypeDef(_, _, _, _): - case AliasTypeDef(_, _, _, _): - ownerDeclList.add(tree); - return tree; - case Template(Tree[] parents, Tree[] body): - for(int i = 0; i < body.length; i++) - keepDeclarations(body[i], ownerDeclList); - Tree[] ownerDecls = (Tree[]) ownerDeclList.toArray(new Tree[ownerDeclList.size()]); - return global.make.Template(tree.pos, parents, ownerDecls); - default: - return tree; - } - } - -} diff --git a/sources/scala/tools/scaladoc/ScalaSearch.java b/sources/scala/tools/scaladoc/ScalaSearch.java index 5777beca19..23eea17d17 100644 --- a/sources/scala/tools/scaladoc/ScalaSearch.java +++ b/sources/scala/tools/scaladoc/ScalaSearch.java @@ -19,12 +19,11 @@ import java.util.Map; import ch.epfl.lamp.util.Pair; import scalac.Global; -import scalac.ast.Tree; -import scalac.ast.Tree.*; import scalac.symtab.Scope; import scalac.symtab.Scope.SymbolIterator; import scalac.symtab.Symbol; import scalac.symtab.Type; +import scalac.symtab.Modifiers; import scalac.util.Debug; import scalac.util.Name; import scalac.util.NameTransformer; @@ -35,57 +34,137 @@ import scalac.util.NameTransformer; */ public class ScalaSearch { - /** - * Class representing functions on trees. + /////////////////// SYMBOLS TESTERS //////////////////////////// + + /** Test if the given symbol is a class, a package, or an object. */ - public static abstract class TreeFun { - abstract void apply(Tree tree); + static boolean isContainer(Symbol sym) { + return sym.isClass() || sym.isModule() || sym.isPackage(); } - /** - * Apply a function to all definition nodes in a tree. - * - * @param trees - * @param fun + /** Test if the given symbol has a lazy type. */ - public static void foreach(Tree[] trees, TreeFun fun) { - for (int i = 0; i < trees.length; i++) - foreach(trees[i], fun); + static boolean isLazy(Symbol sym) { + return + (sym.rawInfo() instanceof Type.LazyType) || + ((sym.rawInfo() instanceof Type.TypeRef) && + (sym.rawInfo().symbol().rawInfo() instanceof Type.LazyType)); } - /** - * .. - * - * @param trees - * @param fun + /** Test if the given symbol is private (without evaluating its type). + */ + static boolean isPrivate(Symbol sym) { + return (sym.flags & Modifiers.PRIVATE) != 0; + } + + /** Test if the given symbol has been generated by the compiler. + */ + public static boolean isGenerated(Symbol sym) { + return + (sym.isSynthetic() && !sym.isRoot()) || + (sym.isGenerated() && + NameTransformer.decode(sym.name).toString().equals(sym.name.toString())) || + NameTransformer.decode(sym.name).toString().endsWith("_="); + } + + /** Test if the given symbol is relevant for the documentation. + */ + public static boolean isRelevant(Symbol sym) { + return !isGenerated(sym) && !isLazy(sym) && !isPrivate(sym); + } + + /** Test if the given symbol is a documented member, i.e. if it + * appears in the documentation. + */ + public static boolean isDocumented(Symbol sym) { + return isRelevant(sym) || + (sym.isModuleClass() && isRelevant(sym.module())); + } + + //////////////////////// SCOPE ITERATOR ////////////////////////////// + + /** A symbol iterator that returns all alternatives of an overloaded symbol + * instead of the overloaded symbol itself (does not unload lazy symbols). + */ + public static class UnloadLazyIterator extends SymbolIterator { + private SymbolIterator iterator; + private Symbol[] alternatives; + private int index; + + public UnloadLazyIterator(SymbolIterator iterator) { + this.iterator = iterator; + this.alternatives = null; + this.index = -1; + } + + public boolean hasNext() { + return index >= 0 || iterator.hasNext(); + } + public Symbol next() { + if (index >= 0) { + Symbol symbol = alternatives[index++]; + if (index == alternatives.length) { + alternatives = null; + index = -1; + } + return symbol; + } else { + Symbol symbol = iterator.next(); + if (isLazy(symbol)) + return symbol; + else { + switch (symbol.type()) { + case OverloadedType(Symbol[] alts, _): + alternatives = alts; + index = 0; + return next(); + default: + return symbol; + } + } + } + } + } + + ////////////////////////// TRAVERSER /////////////////////////////// + + /** Function from Symbol to void. + */ + public static abstract class SymFun { + abstract void apply(Symbol sym); + } + + /** Apply a given function to all symbols below the given symbol + * in the symbol table. + */ + public static void foreach(Symbol sym, SymFun fun) { + if (isRelevant(sym)) { + fun.apply(sym); + Symbol[] members = members(sym); + for(int i = 0; i < members.length; i++) + foreach(members[i], fun); + } + } + + /** Return all members of a container symbol. */ - public static void foreach(Tree tree, TreeFun fun) { - switch(tree) { - case ClassDef(int mods, Name name, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): - fun.apply(tree); - foreach(impl, fun); - break; - case ModuleDef(int mods, Name name, Tree tpe, Template impl): - fun.apply(tree); - foreach(impl, fun); - break; - case ValDef(int mods, Name name, Tree tpe, Tree rhs): - fun.apply(tree); - break; - case DefDef(int mods, Name name, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): - fun.apply(tree); - break; - case AbsTypeDef(_, _, _, _): - case AliasTypeDef(_, _, _, _): - fun.apply(tree); - break; - case Template(Tree[] parents, Tree[] body): - foreach(body, fun); - break; - default: + public static Symbol[] members(Symbol sym) { + if (isContainer(sym) && !isLazy(sym)) { + List memberList = new LinkedList(); + SymbolIterator i = new UnloadLazyIterator(sym.members().iterator(false)); + while (i.hasNext()) { + Symbol member = i.next(); + if (isRelevant(member)) + memberList.add(member); + } + return (Symbol[]) memberList.toArray(new Symbol[memberList.size()]); } + else + return new Symbol[0]; } + ///////////////////////// COMPARATORS /////////////////////////////// + /** * Use the simple name of symbols to order them. */ @@ -118,141 +197,53 @@ public class ScalaSearch { } }; - /** - * Use the simple name of trees to order them. - */ - public static Comparator alphaOrder = new Comparator() { - public int compare(Object o1, Object o2) { - Tree tree1 = (Tree) o1; - Tree tree2 = (Tree) o2; - assert tree1.hasSymbol() : tree1; - assert tree2.hasSymbol() : tree2; - String name1 = NameTransformer.decode(tree1.symbol().name).toString(); - String name2 = NameTransformer.decode(tree2.symbol().name).toString(); - return name1.compareTo(name2); - } - public boolean equals(Object o) { - return false; - } - }; - - /** - * Use the fully qualified name of trees to order them. - */ - public static Comparator fullPathOrder = new Comparator() { - public int compare(Object o1, Object o2) { - Tree tree1 = (Tree) o1; - Tree tree2 = (Tree) o2; - assert tree1.hasSymbol(); - assert tree2.hasSymbol(); - String name1 = tree1.symbol().fullName().toString(); - String name2 = tree2.symbol().fullName().toString(); - return name1.compareTo(name2); - } - public boolean equals(Object o) { - return false; - } - }; - - /** - * Use the non qualified name of trees to order them. - */ - public static Comparator pathOrder = new Comparator() { - public int compare(Object o1, Object o2) { - Tree tree1 = (Tree) o1; - Tree tree2 = (Tree) o2; - assert tree1.hasSymbol(); - assert tree2.hasSymbol(); - String name1 = tree1.symbol().nameString(); - String name2 = tree2.symbol().nameString(); - return name1.compareTo(name2); - } - public boolean equals(Object o) { - return false; - } - }; + ///////////////////////// COLLECTORS //////////////////////////// /** - * Returns the sorted list of packages in the root tree. + * Returns the sorted list of packages from the root symbol. * * @param root */ - public static Tree[] getSortedPackageList(Tree root) { + public static Symbol[] getSortedPackageList(Symbol root) { final List packagesAcc = new LinkedList(); foreach(root, - new TreeFun() { - void apply(Tree tree) { - if (tree.hasSymbol() && tree.symbol().isPackage()) - packagesAcc.add(tree); + new SymFun() { + void apply(Symbol sym) { + if (sym.isPackage()) + packagesAcc.add(sym); } }); - Tree[] packages = (Tree[]) packagesAcc.toArray(new Tree[packagesAcc.size()]); - Arrays.sort(packages, fullPathOrder); + Symbol[] packages = (Symbol[]) packagesAcc.toArray(new Symbol[packagesAcc.size()]); + Arrays.sort(packages, symPathOrder); return packages; } - /** - * Returns a pair consisting of the sorted list of classes - * and the sorted list of objects in the root tree. - * - * @param root - */ - public static Tree[][] getSortedPackageMemberList(Tree root) { + public static Symbol[][] getSubContainerMembers(Symbol root) { final List objectsAcc = new LinkedList(); final List traitsAcc = new LinkedList(); final List classesAcc = new LinkedList(); foreach(root, - new TreeFun() { - void apply(Tree tree) { - if (tree.hasSymbol()) { - Symbol sym = tree.symbol(); - if (sym.owner().isPackage()) { - if (sym.isTrait()) - traitsAcc.add(tree); - else if (sym.isClass()) - classesAcc.add(tree); - else if (sym.isModule() && !sym.isPackage()) - objectsAcc.add(tree); - } - } + new SymFun() { + void apply(Symbol sym) { + if (sym.isTrait() && !sym.isModuleClass()) + traitsAcc.add(sym); + else if (sym.isClass() && !sym.isModuleClass()) + classesAcc.add(sym); + else if (sym.isModule() && !sym.isPackage()) + objectsAcc.add(sym); } - }); - Tree[] objects = (Tree[]) objectsAcc.toArray(new Tree[objectsAcc.size()]); - Tree[] traits = (Tree[]) traitsAcc.toArray(new Tree[traitsAcc.size()]); - Tree[] classes = (Tree[]) classesAcc.toArray(new Tree[classesAcc.size()]); - Arrays.sort(objects, pathOrder); - Arrays.sort(traits, pathOrder); - Arrays.sort(classes, pathOrder); - return new Tree[][]{ objects, traits, classes }; + } + ); + Symbol[] objects = (Symbol[]) objectsAcc.toArray(new Symbol[objectsAcc.size()]); + Symbol[] traits = (Symbol[]) traitsAcc.toArray(new Symbol[traitsAcc.size()]); + Symbol[] classes = (Symbol[]) classesAcc.toArray(new Symbol[classesAcc.size()]); + Arrays.sort(objects, symAlphaOrder); + Arrays.sort(traits, symAlphaOrder); + Arrays.sort(classes, symAlphaOrder); + return new Symbol[][]{ objects, traits, classes }; } - /** - * Returns a pair consisting of the sorted list of classes - * and the sorted list of objects in the root tree. - * - * @param root - */ - public static Pair containersSortedList(Tree root) { - final List classesAcc = new LinkedList(); - final List objectsAcc = new LinkedList(); - foreach(root, - new TreeFun() { - void apply(Tree tree) { - if (tree.hasSymbol()) { - Symbol sym = tree.symbol(); - if (sym.isClass()) - classesAcc.add(tree); - else if (sym.isModule() && !sym.isPackage()) - objectsAcc.add(tree); - } - } - }); - Tree[] classes = (Tree[]) classesAcc.toArray(new Tree[classesAcc.size()]); - Tree[] objects = (Tree[]) objectsAcc.toArray(new Tree[objectsAcc.size()]); - Arrays.sort(classes, pathOrder); - Arrays.sort(objects, pathOrder); - return new Pair(classes, objects); - } + /////////////////// IMPLEMENTING CLASSES OR OBJECTS ////////////////////// /** * Returns a hashtable which maps each class symbol to the list of @@ -262,81 +253,67 @@ public class ScalaSearch { * * @param root */ - public static Map subTemplates(Tree root) { + public static Map subTemplates(Symbol root) { final Map subs = new HashMap(); - foreach(root, new TreeFun() { void apply(Tree tree) { - if (tree.hasSymbol()) { - Symbol sym = tree.symbol(); - if (sym.isClass() || sym.isModule()) { - Type[] parents = sym.moduleClass().parents(); - for (int i = 0; i < parents.length; i++) { - Symbol parentSymbol = parents[i].symbol(); - List subList = (List) subs.get(parentSymbol); - if (subList == null) { - subList = new LinkedList(); - subs.put(parentSymbol, subList); - } - subList.add(new Pair(sym, parents[i])); + foreach(root, new SymFun() { void apply(Symbol sym) { + if (sym.isClass() || sym.isModule()) { + Type[] parents = sym.moduleClass().parents(); + for (int i = 0; i < parents.length; i++) { + Symbol parentSymbol = parents[i].symbol(); + List subList = (List) subs.get(parentSymbol); + if (subList == null) { + subList = new LinkedList(); + subs.put(parentSymbol, subList); } + subList.add(new Pair(sym, parents[i])); } } - }}); + } + }); return subs; } + //////////////////////// INDEX BUILDER ///////////////////////////// + /** * Returns the list of characters with the sorted list of * members starting with a character. - * Result type = Pair<Character[], Map<Character, Tree[]>> + * Result type = Pair<Character[], Map<Character, Symbol[]>> * * @param root */ - public static Pair index(Tree root) { + public static Pair index(Symbol root) { final Map index = new HashMap(); // collecting - foreach(root, new TreeFun() { void apply(Tree tree) { - if (tree.hasSymbol() /*&& !tree.symbol().isGenerated()*/) { - Symbol sym = tree.symbol(); - String name = NameTransformer.decode(sym.name).toString(); - if (name.length() > 0) { - char ch = Character.toUpperCase(name.charAt(0)); - Character unicode = new Character(ch); - List symList = (List) index.get(unicode); - if (symList == null) { - symList = new LinkedList(); - index.put(unicode, symList); - } - symList.add(tree); + foreach(root, new SymFun() { void apply(Symbol sym) { + String name = sym.nameString(); + if (name.length() > 0) { + char ch = Character.toUpperCase(name.charAt(0)); + Character unicode = new Character(ch); + List symList = (List) index.get(unicode); + if (symList == null) { + symList = new LinkedList(); + index.put(unicode, symList); } + symList.add(sym); } - }}); + } + }); // sorting Character[] chars = (Character[]) index.keySet() .toArray(new Character[index.keySet().size()]); Arrays.sort(chars); for (int i = 0; i < chars.length; i++) { Character car = chars[i]; - List treeList = (List) index.get(car); - Tree[] trees = (Tree[]) treeList.toArray(new Tree[treeList.size()]); - Arrays.sort(trees, alphaOrder); - index.put(car, trees); + List symList = (List) index.get(car); + Symbol[] syms = (Symbol[]) symList.toArray(new Symbol[symList.size()]); + Arrays.sort(syms, symAlphaOrder); + index.put(car, syms); } return new Pair(chars, index); } - /** - * "Try" to determine if a symbol has been generated by the - * compiler. - * - * @param sym - */ - public static boolean isGenerated(Symbol sym) { - return - (sym.isSynthetic() && !sym.isRoot()) || - (sym.isGenerated() && - NameTransformer.decode(sym.name).toString().equals(sym.name.toString())) || - NameTransformer.decode(sym.name).toString().endsWith("_="); - } + //////////////////////////// INHERITED MEMBERS ////////////////////////////// /** * Finds all local and inherited members of a given class or diff --git a/sources/scala/tools/scaladoc/StandardDocModule.java b/sources/scala/tools/scaladoc/StandardDocModule.java index fa99ff8847..ab629df400 100644 --- a/sources/scala/tools/scaladoc/StandardDocModule.java +++ b/sources/scala/tools/scaladoc/StandardDocModule.java @@ -15,7 +15,6 @@ import java.util.Map.Entry; import scalac.Global; import scalac.Unit; -import scalac.ast.Tree; import scalac.symtab.Symbol; import scalac.util.Debug; @@ -40,8 +39,8 @@ public class StandardDocModule { * .. */ public void apply() { - Tree tree = OneTree.apply(global); - HTMLGenerator.apply(tree, global); + HTMLGenerator.apply(global); + //Query.apply(global); } /** diff --git a/sources/scala/tools/scaladoc/SymbolTablePrinter.java b/sources/scala/tools/scaladoc/SymbolTablePrinter.java index 293ee42689..fc2ff51c89 100644 --- a/sources/scala/tools/scaladoc/SymbolTablePrinter.java +++ b/sources/scala/tools/scaladoc/SymbolTablePrinter.java @@ -392,9 +392,9 @@ public abstract class SymbolTablePrinter extends scalac.symtab.SymbolTablePrinte case ConstantType(Type base, Object value): printType(base); - print("("); - print(value.toString()); - print(")"); +// print("("); +// print(value.toString()); +// print(")"); return this; case CompoundType(Type[] parts, Scope members): diff --git a/sources/scala/tools/scaladoc/SymbolTablePrinterFactory.java b/sources/scala/tools/scaladoc/SymbolTablePrinterFactory.java index 0f29789547..9ab62ca889 100644 --- a/sources/scala/tools/scaladoc/SymbolTablePrinterFactory.java +++ b/sources/scala/tools/scaladoc/SymbolTablePrinterFactory.java @@ -9,10 +9,6 @@ package scala.tools.scaladoc; import scalac.Global; -import scalac.ast.Tree; -import scalac.ast.Tree.AbsTypeDef; -import scalac.ast.Tree.Template; -import scalac.ast.Tree.ValDef; import scalac.symtab.Kinds; import scalac.symtab.Modifiers; import scalac.symtab.NoSymbol; @@ -21,6 +17,7 @@ import scalac.symtab.Scope.SymbolIterator; import scalac.symtab.Symbol; import scalac.symtab.Type; import scalac.symtab.Type.*; +//import scalac.symtab.SymbolTablePrinter; import scalac.util.Debug; import scalac.util.Name; import scalac.util.Names; @@ -28,14 +25,14 @@ import scalac.util.Strings; class SymbolTablePrinterFactory { - public static SymbolTablePrinter makeHTML(final Page page, final TreeSymbols treeSymbols) { + public static SymbolTablePrinter makeHTML(final Page page) { return new SymbolTablePrinter(page.getCodePrinter()) { public void printSymbol(Symbol sym, boolean addLink) { String name = sym.nameString(); if (global.debug) name = sym.name.toString(); - if (treeSymbols.contains(sym)) + if (ScalaSearch.isDocumented(sym)) if (addLink) page.printAhref(page.rel(Location.get(sym)), page.destinationFrame, name); @@ -53,7 +50,7 @@ class SymbolTablePrinterFactory { Type result = getTypeToPrintForPrefix0(prefix); if (result == prefix || result == null) { return - cleanPrefix(result, treeSymbols, global); + cleanPrefix(result, global); } prefix = result; } @@ -88,7 +85,7 @@ class SymbolTablePrinterFactory { * * @param prefix */ - static protected Type cleanPrefix(Type prefix, TreeSymbols treeSymbols, Global global) { + static protected Type cleanPrefix(Type prefix, Global global) { if (prefix == null) return null; if (prefix.symbol().kind == Kinds.NONE) return null; if (prefix.symbol().isRoot()) return null; @@ -100,25 +97,25 @@ class SymbolTablePrinterFactory { switch(prefix) { case ThisType(Symbol sym): - if (sym.isPackage() && treeSymbols.contains(sym.module())) + if (sym.isPackage() && ScalaSearch.isDocumented(sym.module())) return null; - else if (treeSymbols.contains(sym)) + else if (ScalaSearch.isDocumented(sym)) return null; else return prefix; case TypeRef(Type pre, Symbol sym, Type[] args): - Type pre1 = cleanPrefix(pre, treeSymbols, global); - if (pre1 == null && args.length == 0 && treeSymbols.contains(sym)) + Type pre1 = cleanPrefix(pre, global); + if (pre1 == null && args.length == 0 && ScalaSearch.isDocumented(sym)) return null; else { pre1 = pre1 == null ? global.definitions.ROOT.thisType() : pre1; return Type.typeRef(pre1, sym, args); } case SingleType(Type pre, Symbol sym): - Type pre1 = cleanPrefix(pre, treeSymbols, global); + Type pre1 = cleanPrefix(pre, global); if (pre1 == null) { if (sym.isClass() || sym.isModule()) - if (treeSymbols.contains(sym)) { + if (ScalaSearch.isDocumented(sym)) { return null; } else @@ -134,4 +131,5 @@ class SymbolTablePrinterFactory { } + } diff --git a/sources/scala/tools/scaladoc/TreeSymbols.java b/sources/scala/tools/scaladoc/TreeSymbols.java deleted file mode 100644 index 79de09900e..0000000000 --- a/sources/scala/tools/scaladoc/TreeSymbols.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.scaladoc; - -import java.util.HashSet; -import java.util.Set; - -import scalac.ast.Tree; -import scalac.ast.Tree.*; -import scalac.symtab.Symbol; -import scalac.util.*; - -/** - * Computes the symbols defined in a syntactic tree. - */ -class TreeSymbols { - - protected Set/*<Symbol>*/ syms; - - public TreeSymbols(Tree tree) { - this.syms = new HashSet(); - traverse(tree); - } - - public boolean contains(Symbol sym) { - boolean res = syms.contains(sym); - if (!res && sym.isModuleClass()) - res = contains(sym.module()); - return res; - } - - protected void traverse(Tree[] members) { - for(int i = 0; i< members.length; i++) - traverse(members[i]); - } - // with - protected void traverse(Tree tree) { - if (tree.hasSymbol() && !ScalaSearch.isGenerated(tree.symbol())) { - switch (tree) { - case PackageDef(Tree packaged, Template impl): - traverse(impl.body); - break; - case ClassDef(int mods, Name name, AbsTypeDef[] tparams, - ValDef[][] vparams, Tree tpe, Template impl): - syms.add(tree.symbol()); - for(int i = 0; i < tparams.length; i++) - syms.add(tparams[i].symbol()); - for(int i = 0; i < vparams.length; i++) - for(int j = 0; j < vparams[i].length; j++) - syms.add(vparams[i][j].symbol()); - traverse(impl.body); - break; - case ModuleDef(int mods, Name name, Tree tpe, Template impl): - syms.add(tree.symbol()); - if (tpe.isMissing()) - traverse(impl.body); - break; - case ValDef(int mods, Name name, Tree tpe, Tree rhs): - syms.add(tree.symbol()); - break; - case DefDef(int mods, Name name, AbsTypeDef[] tparams, - ValDef[][] vparams, Tree tpe, Tree rhs): - - syms.add(tree.symbol()); - for(int i = 0; i < tparams.length; i++) - syms.add(tparams[i].symbol()); - for(int i = 0; i < vparams.length; i++) - for(int j = 0; j < vparams[i].length; j++) - syms.add(vparams[i][j].symbol()); - break; - case AbsTypeDef(_, _, _, _): - case AliasTypeDef(_, _, _, _): - syms.add(tree.symbol()); - break; - default: - } - } - } -} |