Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting: upgrade to v3.8.4-RC4 #4698

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading