summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2005-04-26 12:08:49 +0000
committerIulian Dragos <jaguarul@gmail.com>2005-04-26 12:08:49 +0000
commitbdf2e9f7023a3916d1b41ff7deb0493082fae877 (patch)
tree14bccfd0d25c03c5f105b4fe5b205a293464eff9 /sources
parent427e592c27ff9ce7c079903789b66ae165dbd8a2 (diff)
downloadscala-bdf2e9f7023a3916d1b41ff7deb0493082fae877.tar.gz
scala-bdf2e9f7023a3916d1b41ff7deb0493082fae877.tar.bz2
scala-bdf2e9f7023a3916d1b41ff7deb0493082fae877.zip
Added better type printer.
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/scalac/ast/printer/SwingPrinter.scala4
-rw-r--r--sources/scala/tools/scalac/ast/printer/TreeInfo.scala49
2 files changed, 50 insertions, 3 deletions
diff --git a/sources/scala/tools/scalac/ast/printer/SwingPrinter.scala b/sources/scala/tools/scalac/ast/printer/SwingPrinter.scala
index 436253213d..57cb7ee2db 100644
--- a/sources/scala/tools/scalac/ast/printer/SwingPrinter.scala
+++ b/sources/scala/tools/scalac/ast/printer/SwingPrinter.scala
@@ -190,7 +190,7 @@ class WindowFrame {
val topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPane, topRightPane);
topPane.add(new JScrollPane(tree), BorderLayout.CENTER);
- topRightPane.add(infoPanel, BorderLayout.CENTER);
+ topRightPane.add(new JScrollPane(infoPanel), BorderLayout.CENTER);
bottomPane.add(new JScrollPane(textArea), BorderLayout.CENTER);
textArea.setFont(new Font("monospaced", Font.PLAIN, 14));
@@ -248,7 +248,7 @@ class InfoPanel extends JPanel() {
symLabel.setText(TreeInfo.symbolText(t));
stypeLabel.setText(TreeInfo.symbolTypeText(t));
attLabel.setText(TreeInfo.symbolAttributes(t));
- ttypeLabel.setText(t.`type`().toString());
+ ttypeLabel.setText(t.getType().toString());
} else
reset;
diff --git a/sources/scala/tools/scalac/ast/printer/TreeInfo.scala b/sources/scala/tools/scalac/ast/printer/TreeInfo.scala
index b693ac73b3..e83ef5535c 100644
--- a/sources/scala/tools/scalac/ast/printer/TreeInfo.scala
+++ b/sources/scala/tools/scalac/ast/printer/TreeInfo.scala
@@ -342,7 +342,8 @@ object TreeInfo {
def symbolTypeText(t: Tree): String = {
val s = t.symbol();
if (s != null)
- s.`type`().toString();
+// s.`type`().toString();
+ TypePrinter.apply(s.getType());
else
"";
}
@@ -369,4 +370,50 @@ object TreeInfo {
}
}
+ object TypePrinter {
+ def apply(t: Type): String = t match {
+ case Type.ThisType(s) => "ThisType(" + s.name + ")\n";
+ case Type.SingleType(pre, s) => "SingleType(" + apply(pre) + ", " + s.name + ")\n";
+ case Type.ConstantType(base, value) => "ConstantType(" + apply(base) + ", " + value + ")\n";
+ case Type.TypeRef(pre, s, args) => "TypeRef(" + apply(pre) + ", " + s.name + ", " + apply(args) + ")\n)";
+ case Type.CompoundType(parts, members) => "CompoundType(" + apply(parts) + ", [members])\n";
+ case Type.MethodType(vparams, result) => "MethodType( (" + apply(vparams) + "), " + apply(result) + ")\n";
+ case Type.PolyType(tparams, result) => "PolyType( (" + apply(tparams) + "), " + apply(result) + ")\n";
+ case Type.OverloadedType(alts, alttypes) => "OverloadedType()";
+ case Type.LazyType() => "LazyType()\n";
+ case Type.TypeVar(orig, constr) => "TypeVar()";
+ case Type.UnboxedType(tag) => "UnboxedType(" + tag + ");\n";
+ case Type.UnboxedArrayType(tag) => "UnboxedArrayType(" + tag + ")\n";
+ case _ => "<unknown case>[" + t + "]";
+ }
+
+ def apply(ts: Array[Type]): String = {
+ var s: StringBuffer = new StringBuffer();
+ var i: Int = 0;
+
+ while (i < ts.length) {
+ s.append(apply(ts(i)));
+ if (i != ts.length - 1)
+ s.append(", ");
+ i = i + 1;
+ }
+ s.toString();
+ }
+
+ def apply(ts: Array[Symbol]): String = {
+ var s: StringBuffer = new StringBuffer();
+ var i: Int = 0;
+
+ while (i < ts.length) {
+ s.append(apply(ts(i).getType()));
+ if (i != ts.length - 1)
+ s.append(", ");
+ i = i + 1;
+ }
+ s.toString();
+ }
+
+ }
+
+
} // package