Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Conversation

@julienrf
Copy link
Contributor

@julienrf julienrf commented Jan 19, 2018

I created two subdirectories, scalafix/2.12 and scalafix/2.13 to support two kinds of rules: (1) migration from a 2.12 code base to a 2.12 code base using the strawman as a library, and (2) migration of a 2.12 code base to a 2.13 code base (where the standard collection is the strawman).

A consequence is that I can not anymore use the nice github scheme in scalafix URLs (see here) but the 2.12 and 2.13.

cc @olafurpg.

collectionsScalaVersionSettings,
fork in Test := true,
javaOptions in Test += "-Xss1M",
libraryDependencies ++= Seq(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, a side-effect of the changes in this file is that the project can be imported without errors in IntelliJ.

@olafurpg
Copy link
Contributor

What do you think would be the most convenient to support different directories for rules without missing github: scheme support? For example, we could read a URL parameter github:scala/collection-strawman?id=2.13 and that would use 2.13 instead of the default rules directory.

@julienrf
Copy link
Contributor Author

I wouldn’t put in scalafix something that specific to the collection-strawman project. Also, I’m not sure I will keep the 2.12 rewrite because it is super hard to get right (because of we have to unimport several default imports)


def replaceCopyToBuffer(ctx: RuleCtx): Patch =
ctx.tree.collect {
case t @ q"${copyToBuffer(Term.Select(collection, _))}($buffer)" =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pro tip, you can put the collection qualifier like this to avoid Term.Select

@ val q"$qual.${q"foo"}(..$arg)" = q"qual.foo(1, 2)"
qual: Term = Term.Name("qual")
arg: List[Term] = List(Lit.Int(1), Lit.Int(2))

People have different tastes however, I personally prefer Term.Select :)

@julienrf julienrf merged commit 73edfbb into scala:master Jan 22, 2018
@julienrf julienrf deleted the new-rewrite-rules branch January 22, 2018 08:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants