File tree 3 files changed +19
-1
lines changed
scalafix-cli/src/main/scala/scalafix/internal/v1
scalafix-core/src/main/scala/scalafix/v1
scalafix-testkit/src/main/scala/scalafix/testkit
3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,9 @@ object MainOps {
264
264
val N = files.length
265
265
val width = N .toString.length
266
266
var exit = ExitStatus .Ok
267
+
268
+ args.rules.rules.foreach(_.beforeStart())
269
+
267
270
files.foreach { file =>
268
271
if (args.args.verbose) {
269
272
val message = s " Processing (% ${width}s/%s) %s " .format(i, N , file)
@@ -273,6 +276,9 @@ object MainOps {
273
276
val next = handleFile(args, file)
274
277
exit = ExitStatus .merge(exit, next)
275
278
}
279
+
280
+ args.rules.rules.foreach(_.afterComplete())
281
+
276
282
adjustExitCode(args, exit, files)
277
283
}
278
284
Original file line number Diff line number Diff line change @@ -34,6 +34,17 @@ abstract class Rule(val name: RuleName) {
34
34
* on the website.
35
35
*/
36
36
def isExperimental : Boolean = false
37
+
38
+ /**
39
+ * Called before the rule starts processing documents
40
+ */
41
+ def beforeStart (): Unit = {}
42
+
43
+ /**
44
+ * Called after all documents have been processed
45
+ */
46
+ def afterComplete (): Unit = {}
47
+
37
48
}
38
49
39
50
abstract class SyntacticRule (name : RuleName ) extends Rule (name) {
Original file line number Diff line number Diff line change @@ -41,8 +41,9 @@ abstract class SemanticRuleSuite(val props: TestkitProperties)
41
41
def runOn (diffTest : RuleTest ): Unit = {
42
42
test(diffTest.path.testName) {
43
43
val (rule, sdoc) = diffTest.run.apply()
44
+ rule.rules.foreach(_.beforeStart())
44
45
val (fixed, messages) = rule.semanticPatch(sdoc, suppress = false )
45
-
46
+ rule.rules.foreach(_.afterComplete())
46
47
val tokens = fixed.tokenize.get
47
48
val obtained = SemanticRuleSuite .stripTestkitComments(tokens)
48
49
val expected = diffTest.path.resolveOutput(props) match {
You can’t perform that action at this time.
0 commit comments