@@ -4,10 +4,14 @@ We are happy to announce the release of [scalafix v0.3][scalafix].
4
4
This release introduces a new ` Rewrite ` and ` Patch ` API powered by the [ scala.meta semantic API] [ meta-1.6 ] .
5
5
We are excited about this release because we believe it enables a number promising tooling applications.
6
6
7
- This first release of the scala.meta semantic API enables rewrites to query for the "symbol" of a name that appears in a Scala source file.
7
+ Scala.meta recently had its first release of its semantic API; the semantic API provides operations to query information from the compiler.
8
+ This has enabled rewrites in scalafix to query for the so-called "symbol" of a name that appears in a Scala source file.
8
9
A symbol is a unique identifier of a definition such as a class, val, def or trait.
9
10
This ability to query for symbols opens possibilities for a great number of refactorings including imports management and identifier renaming.
10
- To demonstrate what rewrites can be implemented with scalafix v0.3, let's take one example.
11
+
12
+ The long-term mission of scalafix is to help automate the migration of deprecated Scala 2.x features to Dotty.
13
+ However, scalafix can be used for more than migrating between Scala versions; it can also be used for ad-hoc library and application migrations.
14
+ To demonstrate what rewrites can be implemented with scalafix v0.3, let's step through an example of a real usecase.
11
15
12
16
## Example: Xor to Either
13
17
@@ -30,7 +34,10 @@ Replace(Symbol("_root_.cats.data.Xor.Left."), q"Left")
30
34
Replace (Symbol (" _root_.cats.data.Xor.Right." ), q " Right " )
31
35
```
32
36
33
- To introduce new imports on renmae, it's possible to pass in ` additionalImports `
37
+ The ` Symbol(_root_...data.Xor) ` part is the scala.meta symbol referencing the class definition of ` cats.data.Xor ` .
38
+ As we saw in the ` either: Xor[HCursor ` diff above, references to ` Xor ` should become ` Either ` after the rewrite.
39
+
40
+ To introduce new imports on rename, it's possible to pass in ` additionalImports `
34
41
``` scala
35
42
Replace (Symbol (" _root_.cats.data.XorT." ), q " EitherT " ,
36
43
additionalImports = List (importer " cats.data.EitherT " )),
0 commit comments