Skip to content
Snippets Groups Projects
Commit 1971b706 authored by Mirco Dotta's avatar Mirco Dotta
Browse files

Updated strategy for collecting annotated @generator class and methods. Refer...

Updated strategy for collecting annotated @generator class and methods. Refer to the funcheck wiki for an exhaustive explanation of this.
parent 41e3cdff
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,9 @@ trait FilterGeneratorAnnotations { ...@@ -37,7 +37,9 @@ trait FilterGeneratorAnnotations {
def filterTreesWithGeneratorAnnotation(Unit: CompilationUnit)(tree: Tree): Boolean = { def filterTreesWithGeneratorAnnotation(Unit: CompilationUnit)(tree: Tree): Boolean = {
lazy val sym = tree.symbol lazy val sym = tree.symbol
tree match { tree match {
case cd: ClassDef => sym.hasAttribute(generator) || abstractSuperClassHasGeneratorAnnotation(sym.superClass) case cd: ClassDef => isAbstractClass(sym) ||
sym.hasAttribute(generator) ||
abstractSuperClassHasGeneratorAnnotation(sym.superClass)
case d: DefDef => sym.hasAttribute(generator) case d: DefDef => sym.hasAttribute(generator)
case _ => false case _ => false
} }
...@@ -51,13 +53,17 @@ trait FilterGeneratorAnnotations { ...@@ -51,13 +53,17 @@ trait FilterGeneratorAnnotations {
superclass match { superclass match {
case NoSymbol => false case NoSymbol => false
case cs: ClassSymbol => case cs: ClassSymbol =>
(cs.hasFlag(scala.tools.nsc.symtab.Flags.ABSTRACT) && (isAbstractClass(cs) && cs.hasAttribute(generator)) ||
cs.hasAttribute(generator)) ||
abstractSuperClassHasGeneratorAnnotation(cs.superClass) abstractSuperClassHasGeneratorAnnotation(cs.superClass)
case _ => case _ =>
assert(false, "expected ClassSymbol, found "+superclass) assert(false, "expected ClassSymbol, found "+superclass)
false false
} }
} }
}
private def isAbstractClass(s: Symbol): Boolean = s match {
case cs: ClassSymbol => cs.hasFlag(scala.tools.nsc.symtab.Flags.ABSTRACT)
case _ => false
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment