Skip to content

Commit

Permalink
Formatting: upgrade to v3.8.4-RC4
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Dec 27, 2024
1 parent bcc33e4 commit 1d22de8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.8.4-RC3
version=3.8.4-RC4
runner.dialect = scala213
project {
git = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ case class ScalafmtConfig(
import ScalafmtConfig._

private[scalafmt] lazy val alignMap: Map[String, Seq[AlignToken.Matcher]] =
align.tokens.map(x => x.code -> x).toMap
.map { case (k, v) => k -> v.getMatcher }
align.tokens.map(x => x.code -> x).toMap.map { case (k, v) =>
k -> v.getMatcher
}

private[scalafmt] def withDialect(dialect: NamedDialect): ScalafmtConfig =
copy(runner = runner.withDialect(dialect))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ class FormatTokens(leftTok2tok: Map[TokenHash, Int])(val arr: Array[FT])
getHeadAndLastIfEnclosed(tree.tokens, tree)

def getDelimsIfEnclosed(tokens: Tokens, tree: Tree): Option[(FT, FT)] =
getHeadAndLastIfEnclosed(tokens, tree)
.flatMap { case (head, lastOpt) => lastOpt.map(last => (head, last)) }
getHeadAndLastIfEnclosed(tokens, tree).flatMap { case (head, lastOpt) =>
lastOpt.map(last => (head, last))
}
def getDelimsIfEnclosed(tree: Tree): Option[(FT, FT)] =
getDelimsIfEnclosed(tree.tokens, tree)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ final class State(
): Option[FT] = getLineStartOwner(isComment)
.flatMap { case (lineFt, lineOwner) =>
val ft = tokens(depth)
val ok = {
val ok =
// comment could be preceded by a comma
isComment && ft.left.is[T.Comma] &&
(tokens.prev(ft).meta.leftOwner match {
case `lineOwner` => true
case t: Member.SyntaxValuesClause => t.parent.contains(lineOwner)
case _ => false
})
} || findTreeOrParentSimple(ft.meta.leftOwner)(_ eq lineOwner).isDefined
(tokens.prev(ft).meta.leftOwner match {
case `lineOwner` => true
case t: Member.SyntaxValuesClause => t.parent.contains(lineOwner)
case _ => false
}) || findTreeOrParentSimple(ft.meta.leftOwner)(_ eq lineOwner)
.isDefined
if (ok) Some(lineFt) else None
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@ class RedundantBraces(implicit val ftoks: FormatTokens)
}
else null
case Some(f: Term.FunctionTerm)
if getBlockToReplaceAsFuncBodyIfInSingleArgApply(f)
.exists { case (_, xft) => xft.idx <= ft.idx + 1 } =>
removeToken
if getBlockToReplaceAsFuncBodyIfInSingleArgApply(f).exists {
case (_, xft) => xft.idx <= ft.idx + 1
} => removeToken
case Some(_: Term.Interpolate) => handleInterpolation
case Some(_: Term.Xml) => null
case Some(_: Term.Annotate) => null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ object TreeOps {
private def getBraces[A](tree: Tree, values: List[A])(implicit
ftoks: FormatTokens,
): Option[(FT, A, FT)] = values match {
case arg :: Nil => ftoks.getBracesIfEnclosed(tree)
.map { case (b, e) => (b, arg, e) }
case arg :: Nil => ftoks.getBracesIfEnclosed(tree).map { case (b, e) =>
(b, arg, e)
}
case _ => None
}

Expand Down

0 comments on commit 1d22de8

Please sign in to comment.