@@ -135,8 +135,8 @@ class ScoverageComponent(val global: Global)
135135
136136 def  process (tree : Tree ):  Tree  =  {
137137 if  (tree.hasSymbol) {
138-  //   if (tree.symbol.isClassConstructor )
139-  //   println("CLASS CONSTRUCTOR : " + tree.symbol + " " + tree)
138+  if  (tree.symbol.isSynthetic )
139+    println(" isDerivedValueClass!!!! : " +  tree.symbol +  "  " +  tree)
140140 // if (tree.symbol.is)
141141 // println("PRIMARY CONSTRUCTOR: " + tree.symbol + " " + tree)
142142 }
@@ -175,6 +175,10 @@ class ScoverageComponent(val global: Global)
175175 case  _ : Import  =>  super .transform(tree)
176176 case  p : PackageDef  =>  super .transform(tree)
177177
178+  case  d : ClassDef  if  d.symbol.isSynthetic => 
179+  println(" SYNTH CLASS: " +  d.toString() +  "  " +  d.symbol)
180+  super .transform(tree)
181+ 
178182 //  scalac generated classes, we just instrument the enclosed methods/statments
179183 //  the location would stay as the source class
180184 case  c : ClassDef  if  c.symbol.isAnonymousClass ||  c.symbol.isAnonymousFunction => 
@@ -184,6 +188,10 @@ class ScoverageComponent(val global: Global)
184188 updateLocation(c.symbol)
185189 super .transform(tree)
186190
191+  case  d : DefDef  if  d.symbol.isVariable => 
192+  println(" DefDef VAR: " +  d.toString() +  "  " +  d.symbol)
193+  tree
194+ 
187195 //  todo do we really want to ignore?
188196 case  d : DefDef  if  d.symbol.isPrimaryConstructor => 
189197 tree
@@ -207,19 +215,35 @@ class ScoverageComponent(val global: Global)
207215 println(" CASE: " +  d.toString() +  "  " +  d.symbol)
208216 super .transform(tree)
209217
210-  //  top level vals todo should instrument the rhs
211-  case  d : DefDef  if  d.symbol.isStable &&  d.symbol.isAccessor => 
212-  super .transform(tree)
218+  /**  
219+  * Stable getters are methods generated for access to a top level val. 
220+  * Should be ignored as this is compiler generated code. The val definition will be instrumented. 
221+  * 
222+  * Eg 
223+  * <stable> <accessor> def MaxCredit: scala.math.BigDecimal = CreditEngine.this.MaxCredit 
224+  * <stable> <accessor> def alwaysTrue: String = InstrumentLoader.this.alwaysTrue 
225+  * <stable> <accessor> lazy def instruments: Set[com.sksamuel.scoverage.samples.Instrument] = { ... } 
226+  */  
227+  case  d : DefDef  if  d.symbol.isStable &&  d.symbol.isGetter =>  tree
228+ 
229+  /**  Getters are auto generated and should be ignored. 
230+  * 
231+  * Eg 
232+  * <accessor> def cancellable: akka.actor.Cancellable 
233+  * <accessor> private def _clientName: String = 
234+  */  
235+  case  d : DefDef  if  d.symbol.isGetter =>  tree
213236
214237 case  d : DefDef  if  d.symbol.isStable => 
215238 println(" STABLE DEF: " +  d.toString() +  "  " +  d.symbol)
216239 super .transform(tree)
217240
218-  /**  eg for top level vars todo should instrument the rhs 
219-  * <accessor> def cancellable: akka.actor.Cancellable 
241+  /**  Accessors are auto generated setters and getters. 
242+  * Eg 
243+  * <accessor> def cancellable: akka.actor.Cancellable = PriceEngine.this.cancellable 
244+  * <accessor> def cancellable_=(x$1: akka.actor.Cancellable): Unit = PriceEngine.this.cancellable = x$1 
220245 */  
221-  case  d : DefDef  if  d.symbol.isGetter => 
222-  super .transform(tree)
246+  case  d : DefDef  if  d.symbol.isAccessor =>  tree
223247
224248 case  d : DefDef  if  d.symbol.isParamAccessor &&  d.symbol.isAccessor => 
225249 println(" PARAM ACCESSOR: " +  d.toString() +  "  " +  d.symbol)
@@ -250,6 +274,7 @@ class ScoverageComponent(val global: Global)
250274
251275 //  handle function bodies. This AST node corresponds to the following Scala code: vparams => body
252276 case  f : Function  => 
277+  println(" FUNCTION: " +  f.toString() +  "  " +  f.symbol)
253278 treeCopy.Function (tree, f.vparams, process(f.body))
254279
255280 case  _ : Ident  =>  super .transform(tree)
@@ -307,10 +332,29 @@ class ScoverageComponent(val global: Global)
307332
308333 case  _ : TypeTree  =>  super .transform(tree)
309334
310-  //  case param accessors are auto generated
311-  case  v : ValDef  if  v.symbol.isCaseAccessor =>  super .transform(tree)
335+  /**  
336+  * This AST node corresponds to any of the following Scala code: 
337+  * 
338+  * mods `val` name: tpt = rhs 
339+  * 
340+  * mods `var` name: tpt = rhs 
341+  * 
342+  * mods name: tpt = rhs // in signatures of function and method definitions 
343+  * 
344+  * self: Bar => // self-types 
345+  * 
346+  * <synthetic> val default: A1 => B1 = 
347+  * <synthetic> val x1: Any = _ 
348+  */  
349+  case  v : ValDef  if  v.symbol.isSynthetic =>  tree
350+ 
351+  /**  
352+  * Vals declared in case constructors 
353+  */  
354+  case  v : ValDef  if  v.symbol.isParamAccessor &&  v.symbol.isCaseAccessor =>  tree
312355
313356 //  user defined value statements, we will instrument the RHS
357+  //  This includes top level non-lazy vals. Lazy vals are generated as stable defs.
314358 case  v : ValDef  => 
315359 updateLocation(v.symbol)
316360 treeCopy.ValDef (tree, v.mods, v.name, v.tpt, process(v.rhs))
0 commit comments