diff --git a/core/src/main/scala/scalameta_ast/ScalametaAST.scala b/core/src/main/scala/scalameta_ast/ScalametaAST.scala index ff9cb99..cb04e42 100644 --- a/core/src/main/scala/scalameta_ast/ScalametaAST.scala +++ b/core/src/main/scala/scalameta_ast/ScalametaAST.scala @@ -539,13 +539,15 @@ class ScalametaAST { ): String = { val p = patchCode(patch) val imports = List[List[String]]( - List("scalafix.Patch"), p.imports, List( + "scala.meta.transversers._", + "scalafix.Patch", "scalafix.v1.SyntacticDocument", "scalafix.v1.SyntacticRule", + "scalafix.v1.XtensionSeqPatch", ) - ).flatten.map("import " + _) + ).flatten.map("import " + _).sorted s"""${header(x = x, packageName = packageName, wildcardImport = wildcardImport, parsed = parsed)} |${imports.mkString("\n")} | @@ -571,13 +573,15 @@ class ScalametaAST { ): String = { val p = patchCode(patch) val imports = List[List[String]]( - List("scalafix.Patch"), p.imports, List( + "scala.meta.transversers._", + "scalafix.Patch", "scalafix.v1.SemanticDocument", "scalafix.v1.SemanticRule", + "scalafix.v1.XtensionSeqPatch", ) - ).flatten.map("import " + _) + ).flatten.map("import " + _).sorted s"""${header(x = x, packageName = packageName, wildcardImport = wildcardImport, parsed = parsed)} |${imports.mkString("\n")} | diff --git a/core/src/test/scala/scalameta_ast/ScalametaASTSpec.scala b/core/src/test/scala/scalameta_ast/ScalametaASTSpec.scala index 72d35b4..810e7b9 100644 --- a/core/src/test/scala/scalameta_ast/ScalametaASTSpec.scala +++ b/core/src/test/scala/scalameta_ast/ScalametaASTSpec.scala @@ -30,11 +30,13 @@ class ScalametaASTSpec extends AnyFreeSpec { |import scala.meta.Lit |import scala.meta.Pat |import scala.meta.Term + |import scala.meta.transversers._ |import scalafix.Patch |import scalafix.lint.Diagnostic |import scalafix.lint.LintSeverity |import scalafix.v1.SyntacticDocument |import scalafix.v1.SyntacticRule + |import scalafix.v1.XtensionSeqPatch | |class Example extends SyntacticRule("Example") { | override def fix(implicit doc: SyntacticDocument): Patch = { @@ -97,9 +99,11 @@ class ScalametaASTSpec extends AnyFreeSpec { s"""package package_name | |import scala.meta.Term + |import scala.meta.transversers._ |import scalafix.Patch |import scalafix.v1.SyntacticDocument |import scalafix.v1.SyntacticRule + |import scalafix.v1.XtensionSeqPatch | |class Example extends SyntacticRule("Example") { | override def fix(implicit doc: SyntacticDocument): Patch = { diff --git a/localServer/src/test/resources/semantic.txt b/localServer/src/test/resources/semantic.txt index f0611a6..32b98ed 100644 --- a/localServer/src/test/resources/semantic.txt +++ b/localServer/src/test/resources/semantic.txt @@ -2,11 +2,13 @@ package fix import scala.meta.Defn import scala.meta.Term +import scala.meta.transversers._ import scalafix.Patch import scalafix.lint.Diagnostic import scalafix.lint.LintSeverity import scalafix.v1.SemanticDocument import scalafix.v1.SemanticRule +import scalafix.v1.XtensionSeqPatch class Example extends SemanticRule("Example") { override def fix(implicit diff --git a/localServer/src/test/resources/syntactic.txt b/localServer/src/test/resources/syntactic.txt index 14cf664..37f068f 100644 --- a/localServer/src/test/resources/syntactic.txt +++ b/localServer/src/test/resources/syntactic.txt @@ -2,11 +2,13 @@ package fix import scala.meta.Defn import scala.meta.Term +import scala.meta.transversers._ import scalafix.Patch import scalafix.lint.Diagnostic import scalafix.lint.LintSeverity import scalafix.v1.SyntacticDocument import scalafix.v1.SyntacticRule +import scalafix.v1.XtensionSeqPatch class Example extends SyntacticRule("Example") { override def fix(implicit diff --git a/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala b/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala index e300c0a..c8b1281 100644 --- a/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala +++ b/localServer/src/test/scala/scalameta_ast/IntegrationTest.scala @@ -403,7 +403,8 @@ abstract class IntegrationTest( .toList assert( diff == List( - ("import scala.meta._", "import scala.meta.*") + ("import scala.meta._", "import scala.meta.*"), + ("import scala.meta.transversers._", "import scala.meta.transversers.*"), ) ) }