summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-07-19 12:56:02 +0000
committermichelou <michelou@epfl.ch>2006-07-19 12:56:02 +0000
commitd21d4888b3e9dd39dd9c4460e7ced2a93a9fff77 (patch)
treeffdef2cdbc0feb9203ff5c5469bc1119c1000673 /src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
parentab1b3687202bdce0824a7f567b32c7a4a406f1a0 (diff)
downloadscala-d21d4888b3e9dd39dd9c4460e7ced2a93a9fff77.tar.gz
scala-d21d4888b3e9dd39dd9c4460e7ced2a93a9fff77.tar.bz2
scala-d21d4888b3e9dd39dd9c4460e7ced2a93a9fff77.zip
removed leading/trailing tabs/blanks, added hea...
removed leading/trailing tabs/blanks, added headers and comments
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala452
1 files changed, 228 insertions, 224 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
index 2a91c9a131..2d082b4b83 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
@@ -1,46 +1,49 @@
-/* NSC -- new scala compiler
- * Copyright 2005 LAMP/EPFL
+/* NSC -- new Scala compiler
+ * Copyright 2005-2006 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
-package scala.tools.nsc.ast;
-import scala.concurrent._;
-import symtab.Flags._;
+package scala.tools.nsc.ast
+import scala.concurrent._
+import symtab.Flags._
-import java.lang.Math;
-import java.util.HashMap;
-import java.io.StringWriter;
+import java.lang.Math
+import java.util.HashMap
+import java.io.StringWriter
-import javax.swing.tree._;
-import javax.swing.event.TreeModelListener;
-import javax.swing._;
+import javax.swing.tree._
+import javax.swing.event.TreeModelListener
+import javax.swing._
-import java.awt.BorderLayout;
-import java.awt.{List => awtList, _};
-import java.awt.event._;
+import java.awt.BorderLayout
+import java.awt.{List => awtList, _}
+import java.awt.event._
-import scala.text._;
+import scala.text._
/**
* Tree browsers can show the AST in a graphical and interactive
* way, useful for debugging and understanding.
+ *
+ * @author Martin Odersky
+ * @version 1.0
*/
abstract class TreeBrowsers {
- val global: Global;
- import global._;
- import nme.EMPTY;
+ val global: Global
+ import global._
+ import nme.EMPTY
/** Pseudo tree class, so that all JTree nodes are treated uniformly */
case class ProgramTree(units: List[UnitTree]) extends Tree {
- override def toString(): String = "Program";
+ override def toString(): String = "Program"
}
/** Pseudo tree class, so that all JTree nodes are treated uniformly */
case class UnitTree(unit: CompilationUnit) extends Tree {
- override def toString(): String = unit.toString();
+ override def toString(): String = unit.toString()
}
def create(): SwingBrowser = new SwingBrowser();
@@ -51,99 +54,100 @@ abstract class TreeBrowsers {
class SwingBrowser {
def browse(t: Tree): Unit = {
- val phase: Phase = globalPhase;
+ val phase: Phase = globalPhase
- val tm = new ASTTreeModel(t);
+ val tm = new ASTTreeModel(t)
- val frame = new BrowserFrame();
- frame.setTreeModel(tm);
+ val frame = new BrowserFrame()
+ frame.setTreeModel(tm)
- val lock = new Lock();
- frame.createFrame(lock);
+ val lock = new Lock()
+ frame.createFrame(lock)
// wait for the frame to be closed
- lock.acquire;
+ lock.acquire
}
def browse(units: Iterator[CompilationUnit]): Unit =
- browse(units.toList);
+ browse(units.toList)
/** print the whole program */
def browse(units: List[CompilationUnit]): Unit = {
- val phase: Phase = globalPhase;
- var unitList: List[UnitTree] = Nil;
-
+ val phase: Phase = globalPhase
+ var unitList: List[UnitTree] = Nil
for (val i <- units)
- unitList = UnitTree(i) :: unitList;
- val tm = new ASTTreeModel(ProgramTree(unitList));
+ unitList = UnitTree(i) :: unitList
+ val tm = new ASTTreeModel(ProgramTree(unitList))
- val frame = new BrowserFrame();
- frame.setTreeModel(tm);
+ val frame = new BrowserFrame()
+ frame.setTreeModel(tm)
- val lock = new Lock();
- frame.createFrame(lock);
+ val lock = new Lock()
+ frame.createFrame(lock)
// wait for the frame to be closed
- lock.acquire;
+ lock.acquire
}
}
/** Tree model for abstract syntax trees */
class ASTTreeModel(val program: Tree) extends TreeModel {
- var listeners: List[TreeModelListener] = Nil;
+ var listeners: List[TreeModelListener] = Nil
/** Add a listener to this tree */
- def addTreeModelListener(l : TreeModelListener): Unit = listeners = l :: listeners;
+ def addTreeModelListener(l: TreeModelListener): Unit =
+ listeners = l :: listeners
/** Return the index'th child of parent */
- def getChild(parent: Any, index: Int): AnyRef = {
- packChildren(parent).drop(index).head;
- }
+ def getChild(parent: Any, index: Int): AnyRef =
+ packChildren(parent).drop(index).head
/** Return the number of children this 'parent' has */
def getChildCount(parent: Any): Int =
- packChildren(parent).length;
+ packChildren(parent).length
/** Return the index of the given child */
def getIndexOfChild(parent: Any, child: Any): Int =
- packChildren(parent).dropWhile(c => c != child).length;
+ packChildren(parent).dropWhile(c => c != child).length
/** Return the root node */
- def getRoot(): AnyRef = program;
+ def getRoot(): AnyRef = program
/** Test whether the given node is a leaf */
- def isLeaf(node: Any): Boolean = packChildren(node).length == 0;
+ def isLeaf(node: Any): Boolean = packChildren(node).length == 0
def removeTreeModelListener(l: TreeModelListener): Unit =
- listeners remove (x => x == l);
+ listeners remove (x => x == l)
/** we ignore this message for now */
- def valueForPathChanged(path: TreePath, newValue: Any) = ();
+ def valueForPathChanged(path: TreePath, newValue: Any) = ()
/**
* Return a list of children for the given node.
*/
def packChildren(t: Any): List[AnyRef] =
- TreeInfo.children(t.asInstanceOf[Tree]);
+ TreeInfo.children(t.asInstanceOf[Tree])
}
/**
* A window that can host the Tree widget and provide methods for
* displaying information
+ *
+ * @author Iulian Dragos
+ * @version 1.0
*/
class BrowserFrame {
- val frame = new JFrame("Scala AST");
- val topLeftPane = new JPanel(new BorderLayout());
- val topRightPane = new JPanel(new BorderLayout());
- val bottomPane = new JPanel(new BorderLayout());
- var splitPane: JSplitPane = _;
- var treeModel: TreeModel = _;
-
- val textArea: JTextArea = new JTextArea(20, 50);
- val infoPanel = new TextInfoPanel();
+ val frame = new JFrame("Scala AST")
+ val topLeftPane = new JPanel(new BorderLayout())
+ val topRightPane = new JPanel(new BorderLayout())
+ val bottomPane = new JPanel(new BorderLayout())
+ var splitPane: JSplitPane = _
+ var treeModel: TreeModel = _
+ val textArea: JTextArea = new JTextArea(20, 50)
+ val infoPanel = new TextInfoPanel()
/** Create a frame that displays the AST.
*
@@ -154,53 +158,52 @@ abstract class TreeBrowsers {
* especially symbols/types would change while the window is visible.
*/
def createFrame(lock: Lock): Unit = {
- lock.acquire; // keep the lock until the user closes the window
+ lock.acquire // keep the lock until the user closes the window
- frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
frame.addWindowListener(new WindowAdapter() {
/** Release the lock, so compilation may resume after the window is closed. */
- override def windowClosed(e: WindowEvent): Unit = lock.release;
+ override def windowClosed(e: WindowEvent): Unit = lock.release
});
val tree = new JTree(treeModel) {
/** Return the string for a tree node. */
override def convertValueToText(value: Any, sel: Boolean,
- exp: Boolean, leaf: Boolean,
- row: Int, hasFocus: Boolean) = {
- val Pair(cls, name) = TreeInfo.treeName(value.asInstanceOf[Tree]);
+ exp: Boolean, leaf: Boolean,
+ row: Int, hasFocus: Boolean) = {
+ val Pair(cls, name) = TreeInfo.treeName(value.asInstanceOf[Tree])
if (name != EMPTY)
- cls + "[" + name.toString() + "]";
- else
- cls;
-
+ cls + "[" + name.toString() + "]"
+ else
+ cls
}
}
tree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
def valueChanged(e: javax.swing.event.TreeSelectionEvent): Unit = {
- textArea.setText(e.getPath().getLastPathComponent().toString());
- infoPanel.update(e.getPath().getLastPathComponent());
+ textArea.setText(e.getPath().getLastPathComponent().toString())
+ infoPanel.update(e.getPath().getLastPathComponent())
}
- });
+ })
- val topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topLeftPane, topRightPane);
- topSplitPane.setResizeWeight(0.5);
+ val topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topLeftPane, topRightPane)
+ topSplitPane.setResizeWeight(0.5)
- topLeftPane.add(new JScrollPane(tree), BorderLayout.CENTER);
- topRightPane.add(new JScrollPane(infoPanel), BorderLayout.CENTER);
+ topLeftPane.add(new JScrollPane(tree), BorderLayout.CENTER)
+ topRightPane.add(new JScrollPane(infoPanel), BorderLayout.CENTER)
- bottomPane.add(new JScrollPane(textArea), BorderLayout.CENTER);
- textArea.setFont(new Font("monospaced", Font.PLAIN, 14));
- textArea.setEditable(false);
+ bottomPane.add(new JScrollPane(textArea), BorderLayout.CENTER)
+ textArea.setFont(new Font("monospaced", Font.PLAIN, 14))
+ textArea.setEditable(false)
- splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topSplitPane, bottomPane);
- frame.getContentPane().add(splitPane);
- frame.pack();
- frame.setVisible(true);
+ splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topSplitPane, bottomPane)
+ frame.getContentPane().add(splitPane)
+ frame.pack()
+ frame.setVisible(true)
}
- def setTreeModel(tm: TreeModel): Unit = treeModel = tm;
+ def setTreeModel(tm: TreeModel): Unit = treeModel = tm
}
/**
@@ -208,31 +211,31 @@ abstract class TreeBrowsers {
*/
class TextInfoPanel extends JTextArea(30, 40) {
- setFont(new Font("monospaced", Font.PLAIN, 12));
+ setFont(new Font("monospaced", Font.PLAIN, 12))
def update(v: AnyRef): Unit = {
- val t: Tree = v.asInstanceOf[Tree];
- val str = new StringBuffer();
- var buf = new StringWriter();
+ val t: Tree = v.asInstanceOf[Tree]
+ val str = new StringBuffer()
+ var buf = new StringWriter()
t match {
- case ProgramTree(_) => ();
- case UnitTree(_) => ();
+ case ProgramTree(_) => ()
+ case UnitTree(_) => ()
case _ =>
- str.append("Symbol: ").append(TreeInfo.symbolText(t));
- str.append("\nSymbol info: \n");
- TreeInfo.symbolTypeDoc(t).format(getWidth() / getColumnWidth(), buf);
- str.append(buf.toString());
- str.append("\nSymbol tpe: \n");
+ str.append("Symbol: ").append(TreeInfo.symbolText(t))
+ str.append("\nSymbol info: \n")
+ TreeInfo.symbolTypeDoc(t).format(getWidth() / getColumnWidth(), buf)
+ str.append(buf.toString())
+ str.append("\nSymbol tpe: \n")
if (t.symbol != null) {
buf = new StringWriter();
- TypePrinter.toDocument(t.symbol.tpe).format(getWidth() / getColumnWidth(), buf);
- str.append(buf.toString());
+ TypePrinter.toDocument(t.symbol.tpe).format(getWidth() / getColumnWidth(), buf)
+ str.append(buf.toString())
}
- str.append("\nSymbol Attributes: \n").append(TreeInfo.symbolAttributes(t));
- str.append("\nType: \n").append(if (t.tpe ne null) t.tpe.toString() else "");
- }
- setText(str.toString());
+ str.append("\nSymbol Attributes: \n").append(TreeInfo.symbolAttributes(t))
+ str.append("\nType: \n").append(if (t.tpe ne null) t.tpe.toString() else "")
+ }
+ setText(str.toString())
}
}
@@ -246,268 +249,268 @@ abstract class TreeBrowsers {
/** Return the case class name and the Name, if the node defines one */
def treeName(t: Tree): Pair[String, Name] = t match {
case ProgramTree(units) =>
- Pair("Program", EMPTY);
+ Pair("Program", EMPTY)
case UnitTree(unit) =>
- Pair("CompilationUnit", unit.toString());
+ Pair("CompilationUnit", unit.toString())
case DocDef(comment, definition) =>
- Pair("DocDef", EMPTY);
+ Pair("DocDef", EMPTY)
case ClassDef(mods, name, tparams, tpt, impl) =>
- Pair("ClassDef", name);
+ Pair("ClassDef", name)
case PackageDef(packaged, impl) =>
- Pair("PackageDef", EMPTY);
+ Pair("PackageDef", EMPTY)
case ModuleDef(mods, name, impl) =>
- Pair("ModuleDef", name);
+ Pair("ModuleDef", name)
case ValDef(mods, name, tpe, rhs) =>
- Pair("ValDef", name);
+ Pair("ValDef", name)
case DefDef(mods, name, tparams, vparams, tpe, rhs) =>
- Pair("DefDef", name);
+ Pair("DefDef", name)
case AbsTypeDef(mods, name, rhs, lobound) =>
- Pair("AbsTypeDef", name);
+ Pair("AbsTypeDef", name)
case AliasTypeDef(mods, name, tparams, rhs) =>
- Pair("AliasTypeDef", name);
+ Pair("AliasTypeDef", name)
case Import(expr, selectors) =>
- Pair("Import", EMPTY);
+ Pair("Import", EMPTY)
case CaseDef(pat, guard, body) =>
- Pair("CaseDef", EMPTY);
+ Pair("CaseDef", EMPTY)
case Template(parents, body) =>
- Pair("Template", EMPTY);
+ Pair("Template", EMPTY)
case LabelDef(name, params, rhs) =>
- Pair("LabelDef", name);
+ Pair("LabelDef", name)
case Block(stats, expr) =>
- Pair("Block", EMPTY);
+ Pair("Block", EMPTY)
case Sequence(trees) =>
- Pair("Sequence", EMPTY);
+ Pair("Sequence", EMPTY)
case Alternative(trees) =>
- Pair("Alternative", EMPTY);
+ Pair("Alternative", EMPTY)
case Bind(name, rhs) =>
- Pair("Bind", name);
+ Pair("Bind", name)
case Match(selector, cases) =>
- Pair("Visitor", EMPTY);
+ Pair("Visitor", EMPTY)
case Function(vparams, body) =>
- Pair("Function", EMPTY);
+ Pair("Function", EMPTY)
case Assign(lhs, rhs) =>
- Pair("Assign", EMPTY);
+ Pair("Assign", EMPTY)
case If(cond, thenp, elsep) =>
- Pair("If", EMPTY);
+ Pair("If", EMPTY)
case Return(expr) =>
- Pair("Return", EMPTY);
+ Pair("Return", EMPTY)
case Throw(expr) =>
- Pair("Throw", EMPTY);
+ Pair("Throw", EMPTY)
case New(init) =>
- Pair("New", EMPTY);
+ Pair("New", EMPTY)
case Typed(expr, tpe) =>
- Pair("Typed", EMPTY);
+ Pair("Typed", EMPTY)
case TypeApply(fun, args) =>
- Pair("TypeApply", EMPTY);
+ Pair("TypeApply", EMPTY)
case Apply(fun, args) =>
- Pair("Apply", EMPTY);
+ Pair("Apply", EMPTY)
case Super(qualif, mix) =>
- Pair("Super", qualif.toString() + ", mix: " + mix.toString());
+ Pair("Super", qualif.toString() + ", mix: " + mix.toString())
case This(qualifier) =>
- Pair("This", qualifier);
+ Pair("This", qualifier)
case Select(qualifier, selector) =>
- Pair("Select", selector);
+ Pair("Select", selector)
case Ident(name) =>
- Pair("Ident", name);
+ Pair("Ident", name)
case Literal(value) =>
- Pair("Literal", EMPTY);
+ Pair("Literal", EMPTY)
case TypeTree() =>
- Pair("TypeTree", EMPTY);
+ Pair("TypeTree", EMPTY)
case SingletonTypeTree(ref) =>
- Pair("SingletonType", EMPTY);
+ Pair("SingletonType", EMPTY)
case SelectFromTypeTree(qualifier, selector) =>
- Pair("SelectFromType", selector);
+ Pair("SelectFromType", selector)
case CompoundTypeTree(template) =>
- Pair("CompoundType", EMPTY);
+ Pair("CompoundType", EMPTY)
case AppliedTypeTree(tpe, args) =>
- Pair("AppliedType", EMPTY);
+ Pair("AppliedType", EMPTY)
case Try(block, catcher, finalizer) =>
- Pair("Try", EMPTY);
+ Pair("Try", EMPTY)
case EmptyTree =>
- Pair("Empty", EMPTY);
+ Pair("Empty", EMPTY)
case ArrayValue(elemtpt, trees) =>
- Pair("ArrayValue", EMPTY);
+ Pair("ArrayValue", EMPTY)
case Star(t) =>
- Pair("Star", EMPTY);
+ Pair("Star", EMPTY)
}
/** Return a list of children for the given tree node */
def children(t: Tree): List[Tree] = t match {
case ProgramTree(units) =>
- units;
+ units
case UnitTree(unit) =>
- List(unit.body);
+ List(unit.body)
case DocDef(comment, definition) =>
- List(definition);
+ List(definition)
case ClassDef(mods, name, tparams, tpt, impl) => {
- var children: List[Tree] = List();
- children = tparams ::: children;
+ var children: List[Tree] = List()
+ children = tparams ::: children
tpt :: impl :: children
}
case PackageDef(name, stats) =>
- stats;
+ stats
case ModuleDef(mods, name, impl) =>
- List(impl);
+ List(impl)
case ValDef(mods, name, tpe, rhs) =>
- List(tpe, rhs);
+ List(tpe, rhs)
case DefDef(mods, name, tparams, vparams, tpe, rhs) => {
- var children: List[Tree] = List();
- children = tparams ::: children;
- children = List.flatten(vparams) ::: children;
+ var children: List[Tree] = List()
+ children = tparams ::: children
+ children = List.flatten(vparams) ::: children
tpe :: rhs :: children
}
case AbsTypeDef(mods, name, rhs, lobound) =>
- List(rhs, lobound);
+ List(rhs, lobound)
case AliasTypeDef(mods, name, tparams, rhs) => {
- var children: List[Tree] = List();
- children = tparams ::: children;
+ var children: List[Tree] = List()
+ children = tparams ::: children
rhs :: children
}
case Import(expr, selectors) => {
- var children: List[Tree] = List(expr);
+ var children: List[Tree] = List(expr)
children
}
case CaseDef(pat, guard, body) =>
- List(pat, guard, body);
+ List(pat, guard, body)
case Template(parents, body) =>
- parents ::: body;
+ parents ::: body
case LabelDef(name, params, rhs) =>
- params ::: List(rhs);
+ params ::: List(rhs)
case Block(stats, expr) =>
- stats ::: List(expr);
+ stats ::: List(expr)
case Sequence(trees) =>
- trees;
+ trees
case Alternative(trees) =>
- trees;
+ trees
case Bind(name, rhs) =>
- List(rhs);
+ List(rhs)
case Match(selector, cases) =>
- selector :: cases;
+ selector :: cases
case Function(vparams, body) =>
- vparams ::: List(body);
+ vparams ::: List(body)
case Assign(lhs, rhs) =>
- List(lhs, rhs);
+ List(lhs, rhs)
case If(cond, thenp, elsep) =>
- List(cond, thenp, elsep);
+ List(cond, thenp, elsep)
case Return(expr) =>
- List(expr);
+ List(expr)
case Throw(expr) =>
- List(expr);
+ List(expr)
case New(init) =>
- List(init);
+ List(init)
case Typed(expr, tpe) =>
- List(expr, tpe);
+ List(expr, tpe)
case TypeApply(fun, args) =>
- List(fun) ::: args;
+ List(fun) ::: args
case Apply(fun, args) =>
- List(fun) ::: args;
+ List(fun) ::: args
case Super(qualif, mix) =>
- Nil;
+ Nil
case This(qualif) =>
Nil
case Select(qualif, selector) =>
- List(qualif);
+ List(qualif)
case Ident(name) =>
- Nil;
+ Nil
case Literal(value) =>
- Nil;
+ Nil
case TypeTree() =>
- Nil;
+ Nil
case SingletonTypeTree(ref) =>
- List(ref);
+ List(ref)
case SelectFromTypeTree(qualif, selector) =>
- List(qualif);
+ List(qualif)
case CompoundTypeTree(templ) =>
- List(templ);
+ List(templ)
case AppliedTypeTree(tpe, args) =>
- tpe :: args;
+ tpe :: args
case Try(block, catches, finalizer) =>
- block :: catches ::: List(finalizer);
+ block :: catches ::: List(finalizer)
case ArrayValue(elemtpt, elems) =>
- elemtpt :: elems;
+ elemtpt :: elems
case EmptyTree =>
- Nil;
+ Nil
case Star(t) =>
List(t)
@@ -515,38 +518,38 @@ abstract class TreeBrowsers {
/** Return a textual representation of this t's symbol */
def symbolText(t: Tree): String = {
- var prefix = "";
+ var prefix = ""
if (t.hasSymbol)
- prefix = "[has] ";
+ prefix = "[has] "
if (t.isDef)
- prefix = "[defines] ";
+ prefix = "[defines] "
prefix + t.symbol
}
/** Return t's symbol type */
def symbolTypeDoc(t: Tree): Document = {
- val s = t.symbol;
+ val s = t.symbol
if (s != null)
- TypePrinter.toDocument(s.info);
+ TypePrinter.toDocument(s.info)
else
- DocNil;
+ DocNil
}
/** Return a textual representation of (some of) the symbol's
* attributes */
def symbolAttributes(t: Tree): String = {
- val s = t.symbol;
- var att = "";
+ val s = t.symbol
+ var att = ""
if (s != null) {
- var str = flagsToString(s.flags);
+ var str = flagsToString(s.flags)
if (s.hasFlag(STATIC) || s.hasFlag(STATICMEMBER))
str = str + " isStatic ";
str
}
- else "";
+ else ""
}
}
@@ -554,44 +557,44 @@ abstract class TreeBrowsers {
///////////////// Document pretty printer ////////////////
- implicit def view(n: String): Document = DocText(n);
+ implicit def view(n: String): Document = DocText(n)
def toDocument(sym: Symbol): Document =
- toDocument(sym.info);
+ toDocument(sym.info)
def symsToDocument(syms: List[Symbol]): Document = syms match {
- case Nil => DocNil;
- case s :: Nil => Document.group(toDocument(s));
+ case Nil => DocNil
+ case s :: Nil => Document.group(toDocument(s))
case _ =>
Document.group(
syms.tail.foldLeft (toDocument(syms.head) :: ", ") (
- (d: Document, s2: Symbol) => toDocument(s2) :: ", " :/: d) );
+ (d: Document, s2: Symbol) => toDocument(s2) :: ", " :/: d) )
}
def toDocument(ts: List[Type]): Document = ts match {
- case Nil => DocNil;
- case t :: Nil => Document.group(toDocument(t));
+ case Nil => DocNil
+ case t :: Nil => Document.group(toDocument(t))
case _ =>
Document.group(
ts.tail.foldLeft (toDocument(ts.head) :: ", ") (
- (d: Document, t2: Type) => toDocument(t2) :: ", " :/: d) );
+ (d: Document, t2: Type) => toDocument(t2) :: ", " :/: d) )
}
def toDocument(t: Type): Document = t match {
- case ErrorType => "ErrorType()";
- case WildcardType => "WildcardType()";
- case NoType => "NoType()";
- case NoPrefix => "NoPrefix()";
- case ThisType(s) => "ThisType(" + s.name + ")";
+ case ErrorType => "ErrorType()"
+ case WildcardType => "WildcardType()"
+ case NoType => "NoType()"
+ case NoPrefix => "NoPrefix()"
+ case ThisType(s) => "ThisType(" + s.name + ")"
case SingleType(pre, sym) =>
Document.group(
Document.nest(4, "SingleType(" :/:
toDocument(pre) :: ", " :/: sym.name.toString() :: ")")
- );
+ )
case ConstantType(value) =>
- "ConstantType(" + value + ")";
+ "ConstantType(" + value + ")"
case TypeRef(pre, sym, args) =>
Document.group(
@@ -599,27 +602,27 @@ abstract class TreeBrowsers {
toDocument(pre) :: ", " :/:
sym.name.toString() :: ", " :/:
"[ " :: toDocument(args) ::"]" :: ")")
- );
+ )
- case TypeBounds(lo, hi) =>
- Document.group(
- Document.nest(4, "TypeBounds(" :/:
- toDocument(lo) :: ", " :/:
- toDocument(hi) :: ")")
- );
+ case TypeBounds(lo, hi) =>
+ Document.group(
+ Document.nest(4, "TypeBounds(" :/:
+ toDocument(lo) :: ", " :/:
+ toDocument(hi) :: ")")
+ )
case RefinedType(parents, defs) =>
Document.group(
Document.nest(4, "RefinedType(" :/:
toDocument(parents) :: ")")
- );
+ )
case ClassInfoType(parents, defs, clazz) =>
Document.group(
Document.nest(4,"ClassInfoType(" :/:
toDocument(parents) :: ", " :/:
clazz.name.toString() :: ")")
- );
+ )
case MethodType(paramtypes, result) =>
Document.group(
@@ -628,7 +631,7 @@ abstract class TreeBrowsers {
toDocument(paramtypes) :/:
"), ") :/:
toDocument(result) :: ")")
- );
+ )
case PolyType(tparams, result) =>
Document.group(
@@ -637,9 +640,10 @@ abstract class TreeBrowsers {
symsToDocument(tparams) :/:
"), ") :/:
toDocument(result) :: ")")
- );
+ )
- case _ => abort("Unknown case: " + t.toString());
+ case _ =>
+ abort("Unknown case: " + t.toString())
}
}