Skip to content

Commit

Permalink
Merge pull request scalameta#725 from ysusuk/master
Browse files Browse the repository at this point in the history
 scalameta#724: Update rewrite rules docs
  • Loading branch information
ysusuk authored Feb 9, 2017
2 parents beab26f + 1c66359 commit cd6c380
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
45 changes: 44 additions & 1 deletion readme/Configuration.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,52 @@
Default: @b{[]}

@p
@b{NEW}. Semantically preserving rewrites. To enable a
Semantically preserving rewrites. To enable a
rewrite rule, add it to the config like this @b{rewrite.rules = [SortImports]}.

@sect(Rewrite.rewrite2name(AvoidInfix))
@demoStyle(rewriteInfix)
future recover {
case e: ArithmeticException ⇒ 0
} map (_.toString)
Configuration contains include/exclude operator filters (those values are build in, and can't be configured outside)
@ul
@li
Default include filter matches on alpha-num operator name (means that rewrite will be applied, if it's not excluded).
@li
Default exclude filter matches on (means that rewrite won't be applied):
"until",
"to",
"by",
"eq",
"ne",
"should.*",
"contain.*",
"must.*",
"in",
"be",
"taggedAs",
"thrownBy",
"synchronized",
"have",
"when".

@sect(Rewrite.rewrite2name(ExpandImportSelectors))
@demoStyle(rewriteImportSelectors)
import a.{
b,
c
}, h.{
k, l
}
import d.e.{f, g}
import a.{
foo => bar,
zzzz => _,
_
}


@sect(Rewrite.rewrite2name(RedundantBraces))
@demoStyle(rewriteBraces)
object RedundantBraces {
Expand Down
12 changes: 12 additions & 0 deletions readme/src/main/scala/org/scalafmt/readme/Readme.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ object Readme {
val stripMarginStyle =
ScalafmtConfig.default.copy(assumeStandardLibraryStripMargin = true)

val rewriteInfix =
ScalafmtConfig.default.copy(
rewrite = ScalafmtConfig.default.rewrite.copy(
rules = Seq(AvoidInfix)
))

val rewriteImportSelectors =
ScalafmtConfig.default.copy(
rewrite = ScalafmtConfig.default.rewrite.copy(
rules = Seq(ExpandImportSelectors)
))

val rewriteBraces =
ScalafmtConfig.default.copy(
rewrite = ScalafmtConfig.default.rewrite.copy(
Expand Down

0 comments on commit cd6c380

Please sign in to comment.