File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -264,6 +264,9 @@ object MainOps {
264264 val N = files.length
265265 val width = N .toString.length
266266 var exit = ExitStatus .Ok
267+
268+ args.rules.rules.foreach(_.beforeStart())
269+
267270 files.foreach { file =>
268271 if (args.args.verbose) {
269272 val message = s " Processing (% ${width}s/%s) %s " .format(i, N , file)
@@ -273,6 +276,9 @@ object MainOps {
273276 val next = handleFile(args, file)
274277 exit = ExitStatus .merge(exit, next)
275278 }
279+
280+ args.rules.rules.foreach(_.afterComplete())
281+
276282 adjustExitCode(args, exit, files)
277283 }
278284
Original file line number Diff line number Diff line change @@ -34,6 +34,17 @@ abstract class Rule(val name: RuleName) {
3434 * on the website.
3535 */
3636 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+
3748}
3849
3950abstract 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)
4141 def runOn (diffTest : RuleTest ): Unit = {
4242 test(diffTest.path.testName) {
4343 val (rule, sdoc) = diffTest.run.apply()
44+ rule.rules.foreach(_.beforeStart())
4445 val (fixed, messages) = rule.semanticPatch(sdoc, suppress = false )
45-
46+ rule.rules.foreach(_.afterComplete())
4647 val tokens = fixed.tokenize.get
4748 val obtained = SemanticRuleSuite .stripTestkitComments(tokens)
4849 val expected = diffTest.path.resolveOutput(props) match {
You can’t perform that action at this time.
0 commit comments