Skip to content

Commit b1c8ca5

Browse files
committed
Added position validating phase
1 parent b96e025 commit b1c8ca5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/test/scala/scoverage/PluginRunner.scala

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,27 @@ class ScoverageAwareCompiler(settings: scala.tools.nsc.Settings, reporter: scala
8888

8989
val preComponent = new ScoveragePreComponent(this)
9090
val instrumentationComponent = new ScoverageInstrumentationComponent(this)
91-
val testStore = new ScoverageTestStoreComponent(this)
9291
instrumentationComponent.setOptions(new ScoverageOptions())
92+
val testStore = new ScoverageTestStoreComponent(this)
93+
val validator = new PositionValidator(this)
94+
95+
class PositionValidator(val global: Global) extends PluginComponent with TypingTransformers with Transform {
96+
97+
val sources = new ListBuffer[String]
98+
99+
override val phaseName: String = "scoverage-validator"
100+
override val runsAfter: List[String] = List("typer")
101+
override val runsBefore = List[String]("scoverage-instrumentation")
102+
103+
override protected def newTransformer(unit: global.CompilationUnit): global.Transformer = new Transformer(unit)
104+
class Transformer(unit: global.CompilationUnit) extends TypingTransformer(unit) {
105+
106+
override def transform(tree: global.Tree) = {
107+
global.validatePositions(tree)
108+
tree
109+
}
110+
}
111+
}
93112

94113
class ScoverageTestStoreComponent(val global: Global) extends PluginComponent with TypingTransformers with Transform {
95114

@@ -116,6 +135,7 @@ class ScoverageAwareCompiler(settings: scala.tools.nsc.Settings, reporter: scala
116135
analyzer.namerFactory -> "resolve names, attach symbols to named trees",
117136
analyzer.packageObjects -> "load package objects",
118137
analyzer.typerFactory -> "the meat and potatoes: type the trees",
138+
validator -> "scoverage validator",
119139
instrumentationComponent -> "scoverage instrumentationComponent",
120140
patmat -> "translate match expressions",
121141
superAccessors -> "add super accessors in traits and nested classes",

0 commit comments

Comments
 (0)