Skip to content
Snippets Groups Projects
Commit 33b377cf authored by Philippe Suter's avatar Philippe Suter
Browse files

amazingly enough I can now tell an object from a class.

parent 0b0e01f1
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,10 @@ class AnalysisComponent(val global: Global, val pluginInstance: FunCheckPlugin)
def apply(unit: CompilationUnit): Unit = {
// (new ForeachTreeTraverser(firstFilter(unit))).traverse(unit.body)
// stopIfErrors
(new ForeachTreeTraverser(findContracts)).traverse(unit.body)
stopIfErrors
(new ForeachTreeTraverser(mircoTraverser(unit))).traverse(unit.body)
// (new ForeachTreeTraverser(findContracts)).traverse(unit.body)
// stopIfErrors
(new ForeachTreeTraverser(showObjects)).traverse(unit.body)
// (new ForeachTreeTraverser(mircoTraverser(unit))).traverse(unit.body)
if(pluginInstance.stopAfterAnalysis) {
println("Analysis complete. Now terminating the compiler process.")
......
......@@ -4,9 +4,7 @@ import scala.tools.nsc._
import scala.tools.nsc.plugins._
trait CodeExtraction {
self: Extractors =>
val global: Global
self: AnalysisComponent =>
import global._
import StructuralExtractors._
......@@ -35,4 +33,9 @@ trait CodeExtraction {
case _ => ;
}
def showObjects(tree: Tree): Unit = tree match {
case ObjectDefn(name) => println(name + " appears to be an object.")
case _ => ;
}
}
......@@ -48,6 +48,21 @@ trait Extractors {
case _ => None
}
}
object ObjectDefn {
def unapply(tree: Tree): Option[String] = tree match {
case c @ ClassDef(_, name, tparams, impl) => {
println(name.toString + " is being traversed.")
println(c.symbol)
if(c.symbol.hasFlag(symtab.Flags.MODULE)) {
Some(name.toString)
} else {
None
}
}
case _ => None
}
}
}
object ExpressionExtractors {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment