Skip to content

Commit

Permalink
added a toy traverser demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
psuter committed Feb 16, 2012
1 parent 84d1d37 commit ce5dd7e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/scala/readability/ExtractionComponent.scala
Expand Up @@ -17,6 +17,26 @@ abstract class ExtractionComponent(plugin : Plugin) extends PluginComponent {
class ExtractionPhase(previous : Phase) extends StdPhase(previous) {
def apply(unit : CompilationUnit) : Unit = {
println("The phase is running on compilation unit " + unit + ".")
val dt = new DemoTraverser(unit)
dt.run()
}
}

class DemoTraverser(val unit : CompilationUnit) extends Traverser {
def run() {
traverse(unit.body)
}

override def traverse(tree : Tree) {
tree match {
case v @ ValDef(mods, _, _, rhs) => {
traverse(rhs)
println("Found a" + (if(mods.isMutable) " " else "n im") + "mutable variable definition : ")
println(" - name : " + v.name)
println(" - type : " + v.symbol.tpe.resultType)
}
case _ => super.traverse(tree)
}
}
}
}

0 comments on commit ce5dd7e

Please sign in to comment.