Skip to content

Commit 45fce24

Browse files
committed
#45 No need for pre-component now
1 parent f052b1e commit 45fce24

File tree

2 files changed

+6
-37
lines changed

2 files changed

+6
-37
lines changed

src/main/scala/scoverage/plugin.scala

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ class ScoveragePlugin(val global: Global) extends Plugin {
1313

1414
override val name: String = "scoverage"
1515
override val description: String = "scoverage code coverage compiler plugin"
16-
val preComponent = new ScoveragePreComponent(global)
1716
val instrumentationComponent = new ScoverageInstrumentationComponent(global)
18-
override val components: List[PluginComponent] = List(preComponent, instrumentationComponent)
17+
override val components: List[PluginComponent] = List(instrumentationComponent)
1918

2019
override def processOptions(opts: List[String], error: String => Unit) {
2120
val options = new ScoverageOptions
@@ -46,35 +45,6 @@ class ScoverageOptions {
4645
var dataDir: String = File.createTempFile("scoverage_datadir_not_defined", ".tmp").getParent
4746
}
4847

49-
class ScoveragePreComponent(val global: Global) extends PluginComponent with TypingTransformers with Transform {
50-
51-
import global._
52-
53-
override val phaseName: String = "scoverage-pre"
54-
override val runsAfter: List[String] = List("parser")
55-
override val runsBefore = List[String]("namer")
56-
57-
override def newPhase(prev: scala.tools.nsc.Phase): Phase = new Phase(prev) {
58-
override def run(): Unit = {
59-
println("[scoverage]: Begin pre-instrumentation phase")
60-
super.run()
61-
println("[scoverage]: Pre-instrumentation complete")
62-
}
63-
}
64-
65-
protected def newTransformer(unit: CompilationUnit): Transformer = new Transformer(unit)
66-
class Transformer(unit: global.CompilationUnit) extends TypingTransformer(unit) {
67-
override def transform(tree: Tree) = {
68-
tree match {
69-
// case v: ValDef if v.mods.isFinal =>
70-
// treeCopy.ValDef(v, v.mods.&~(ModifierFlags.FINAL), v.name, v.tpt, v.rhs)
71-
case _ =>
72-
super.transform(tree)
73-
}
74-
}
75-
}
76-
}
77-
7848
class ScoverageInstrumentationComponent(val global: Global)
7949
extends PluginComponent
8050
with TypingTransformers

src/test/scala/scoverage/PluginRunner.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package scoverage
22

3-
import java.io.{FileNotFoundException, File}
4-
import scala.tools.nsc.transform.{TypingTransformers, Transform}
3+
import java.io.{File, FileNotFoundException}
54
import java.net.URL
6-
import scala.tools.nsc.plugins.PluginComponent
7-
import scala.tools.nsc.{Phase, Global}
5+
86
import scala.collection.mutable.ListBuffer
7+
import scala.tools.nsc.Global
8+
import scala.tools.nsc.plugins.PluginComponent
9+
import scala.tools.nsc.transform.{Transform, TypingTransformers}
910

1011
/** @author Stephen Samuel */
1112
trait PluginSupport {
@@ -87,7 +88,6 @@ trait PluginSupport {
8788
class ScoverageAwareCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tools.nsc.reporters.Reporter)
8889
extends scala.tools.nsc.Global(settings, reporter) {
8990

90-
val preComponent = new ScoveragePreComponent(this)
9191
val instrumentationComponent = new ScoverageInstrumentationComponent(this)
9292
instrumentationComponent.setOptions(new ScoverageOptions())
9393
val testStore = new ScoverageTestStoreComponent(this)
@@ -130,7 +130,6 @@ class ScoverageAwareCompiler(settings: scala.tools.nsc.Settings, reporter: scala
130130
override def computeInternalPhases() {
131131
val phs = List(
132132
syntaxAnalyzer -> "parse source into ASTs, perform simple desugaring",
133-
preComponent -> "scoverage preComponent",
134133
analyzer.namerFactory -> "resolve names, attach symbols to named trees",
135134
analyzer.packageObjects -> "load package objects",
136135
analyzer.typerFactory -> "the meat and potatoes: type the trees",

0 commit comments

Comments
 (0)