You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blog/_posts/2017-02-25-scalafix-v0.3.md
+8-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,12 @@ by: Ólafur Páll Geirsson
5
5
title: "Refactor with scalafix v0.3"
6
6
---
7
7
8
-
I am happy to announce the release of [scalafix v0.3][scalafix].
9
-
This release uses the new scala.meta semantic API to provide a re-designed `Rewrite` and `Patch` API for refactorings.
8
+
I am happy to announce the release of [scalafix v0.3][scalafix], a library and tool to rewrite Scala source code.
9
+
The long-term mission of scalafix is to help automate the migration of between Scala versions.
10
+
However, as I hope to demonstrate in this post, scalafix can be used for more than just migrating between Scala versions.
11
+
Scalafix can also be used for ad-hoc library and application migrations.
12
+
13
+
Scalafix v0.3 uses the new scala.meta semantic API to provide a re-designed `Rewrite` and `Patch` API to implement custom refactorings.
10
14
Let me explain what that means word by word.
11
15
12
16
> Note. This is the second post on scalafix and scala.meta. You might be
@@ -46,7 +50,7 @@ Example token patches are `Remove(token)` and `AddLeft(token, toAdd: String)`, w
46
50
47
51
Tree patches are high-level and allow rewrite author to declaratively explain what operation to perform.
48
52
An example tree patch is `AddGlobalImport(importer)`, which adds a new import to the top of a file if it does not exist.
49
-
Observe that `AddGlobalImport` does not worry about token-level details such as whether the user groups imports by prefix (e.g., `import a.{b, c}`).
53
+
Observe that `AddGlobalImport` does not worry about token-level details such as whether the user groups imports by prefix (`import a.{b, c}`) or not (`import a.b; import a.c`).
50
54
51
55
Tree and token patches build a small algebra of operations that can be composed to build complex refactorings.
52
56
A challenge with composing patches is to figure out what to do on conflicts.
@@ -113,10 +117,6 @@ By using scalafix as a library, you have full control of how, where and when to
113
117
The recommended way to use scalafix as tool is the [`sbt-scalafix`][sbt-scalafix] plugin.
114
118
It's possible define custom tree patches in the [`.scalafix.conf` configuration file][config-patches].
115
119
116
-
The long-term mission of scalafix is to help automate the migration of deprecated Scala 2.x features to Dotty.
117
-
However, as I have demonstrated in this post, scalafix can be used for more than just migrating between Scala versions.
118
-
Scalafix can also be used for ad-hoc library and application migrations.
119
-
120
120
I am excited to see what applications the community can build with scala.meta and scalafix.
121
121
Some promising ideas that have floated around include
122
122
@@ -127,6 +127,7 @@ Some promising ideas that have floated around include
127
127
code-generate a version of the library that uses cats instead.
128
128
- build a code search web-interface with "jump to definition" functionality
129
129
powered by the scala.meta's semantic database.
130
+
- replace usage of `any2stringadd` with string interpolators or explicit `.toString`.
130
131
- replace usage of `scala.Seq`, which can be mutable, in favor of `scala.collection.immutable.Seq`.
0 commit comments