Skip to content

Commit 00cbc8f

Browse files
committed
Update README and CONTRIBUTING files with details related to the migration rules
1 parent 6873b92 commit 00cbc8f

File tree

3 files changed

+104
-3
lines changed

3 files changed

+104
-3
lines changed

CONTRIBUTING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Contributing
2+
3+
## Build
4+
5+
### Sbt Projects
6+
7+
- `scala-collection-compat` project (in the root directory): implementation of the compatibility library ;
8+
- In directory `scalafix/` there is an independent build containing the implementation of the migration tool.
9+
10+
## Migration tool
11+
12+
Several levels of contribution are possible!
13+
14+
### Report a missing case
15+
16+
Create an issue tagged with the
17+
[migration](https://github.com/scala/collection-strawman/labels/migration) label.
18+
Embrace `diff`s to describe differences between the standard collections and
19+
the strawman:
20+
21+
~~~ diff
22+
- xs.toIterator
23+
+ xs.iterator()
24+
~~~
25+
26+
### Add a missing test case
27+
28+
Even better, instead of providing a diff, you can directly add it as a test case!
29+
30+
1. Fork this repository and create a separate branch;
31+
32+
2. Add a file in the `scalafix/input/src/main/scala/fix/` directory with code
33+
that uses the standard collections:
34+
35+
~~~ scala
36+
class toIteratorVsIterator(xs: Iterable[Int]) {
37+
xs.toIterator
38+
}
39+
~~~
40+
41+
3. Add a corresponding file in the `scalafix/output/src/main/scala/fix/` directory
42+
with the same code but using the strawman:
43+
44+
~~~ scala
45+
import strawman.collection.Iterable
46+
47+
class toIteratorVsIterator(xs: Iterable[Int]) {
48+
xs.iterator()
49+
}
50+
~~~
51+
52+
4. Check that your code example compiles
53+
- run sbt from the `scalafix/` directory
54+
and then run the following tasks `; input/compile ; output/compile`;
55+
56+
5. Commit your changes, push your branch to your fork and create a pull request.
57+
58+
Then maybe someone will take over and implement your use case… or maybe you will
59+
(see next section)!
60+
61+
### Implement a missing case
62+
63+
Even better, complete the migration tool implementation to support the missing case!
64+
65+
After you have added the missing case (see previous section), run the following
66+
sbt task (with sbt started from the `scalafix/` directory) to run the
67+
migration tool on the input files and check whether the result matches the
68+
expected output files:
69+
70+
~~~
71+
> tests/test
72+
~~~
73+
74+
Fix the implementation of the rule (in the
75+
`rules/src/main/scala/fix/Scalacollectioncompat_v0.scala` file) until the
76+
tests are green. You can find more help about the scalafix API in its
77+
[documentation](https://scalacenter.github.io/scalafix/docs/rule-authors/setup).

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[![Build Status](https://travis-ci.org/scala/scala-collection-compat.svg?branch=master)](https://travis-ci.org/scala/scala-collection-compat)
22

3-
Scala 2.13 Collection Compatibility Library
4-
===========================================
3+
Scala 2.13 Collection Compatibility Library And Migration Tool
4+
==============================================================
5+
6+
## Compatibility Library
57

68
This library for Scala 2.12 provides limited compatibility with the new collection library in 2.13. We try to keep the
79
2.13 collections as backward compatible as possible but that is not always possible. For some of these cases this
@@ -24,3 +26,25 @@ This project can be cross-built on 2.13 (with new collections) and 2.12. The 2.1
2426
empty `scala.collection.compat` package object that allows you to write `import scala.collection.compat._` in 2.13.
2527
The 2.13 version has the compatibility extensions in this package. It also adds backported version of some new collection
2628
types to other `scala.collection` subpackages.
29+
30+
## Migration Tool
31+
32+
A tool is being developed to automatically migrate code that uses the standard
33+
collection to use the strawman.
34+
35+
To use it, add the [scalafix](https://scalacenter.github.io/scalafix/) sbt plugin
36+
to your build, as explained in
37+
[its documentation](https://scalacenter.github.io/scalafix/#Installation).
38+
39+
The migration tool is not exhaustive and we will continue to improve
40+
it over time. If you encounter a use case that’s not supported, please
41+
report it as described in the
42+
[contributing documentation](CONTRIBUTING.md#migration-tool).
43+
44+
### Migrating a 2.12 code base to 2.13
45+
46+
Run the following sbt task on your project:
47+
48+
~~~
49+
> scalafix github:scala/scala-collection-compat/v0
50+
~~~

scalafix/rules/src/main/scala/fix/Collectionstrawman_v0.scala renamed to scalafix/rules/src/main/scala/fix/Scalacollectioncompat_v0.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scalafix.syntax._
55
import scalafix.util._
66
import scala.meta._
77

8-
case class Collectionstrawman_v0(index: SemanticdbIndex)
8+
case class Scalacollectioncompat_v0(index: SemanticdbIndex)
99
extends SemanticRule(index, "Collectionstrawman_v0") {
1010

1111
def replaceSymbols(ctx: RuleCtx): Patch = {

0 commit comments

Comments
 (0)