Skip to content

Commit

Permalink
PolicyOps: pass rank to SingleLineBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Mar 31, 2023
1 parent dc1fd9d commit 4801dec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,42 +140,49 @@ case class Split(
expire: Token,
exclude: => TokenRanges = TokenRanges.empty,
noSyntaxNL: Boolean = false,
killOnFail: Boolean = false
killOnFail: Boolean = false,
rank: Int = 0
)(implicit fileLine: FileLine): Split =
withSingleLineAndOptimal(
expire,
expire,
exclude,
noSyntaxNL,
killOnFail
killOnFail,
rank
)

def withSingleLineOpt(
expire: Option[Token],
exclude: => TokenRanges = TokenRanges.empty,
noSyntaxNL: Boolean = false,
killOnFail: Boolean = false
killOnFail: Boolean = false,
rank: Int = 0
)(implicit fileLine: FileLine): Split =
expire.fold(this)(
withSingleLine(_, exclude, noSyntaxNL, killOnFail)
withSingleLine(_, exclude, noSyntaxNL, killOnFail, rank)
)

def withSingleLineAndOptimal(
expire: Token,
optimal: Token,
exclude: => TokenRanges = TokenRanges.empty,
noSyntaxNL: Boolean = false,
killOnFail: Boolean = false
killOnFail: Boolean = false,
rank: Int = 0
)(implicit fileLine: FileLine): Split =
withOptimalToken(optimal, killOnFail)
.withSingleLineNoOptimal(expire, exclude, noSyntaxNL)
.withSingleLineNoOptimal(expire, exclude, noSyntaxNL, rank)

def withSingleLineNoOptimal(
expire: Token,
exclude: => TokenRanges = TokenRanges.empty,
noSyntaxNL: Boolean = false
noSyntaxNL: Boolean = false,
rank: Int = 0
)(implicit fileLine: FileLine): Split =
withPolicy(SingleLineBlock(expire, exclude, noSyntaxNL = noSyntaxNL))
withPolicy(
SingleLineBlock(expire, exclude, noSyntaxNL = noSyntaxNL, rank = rank)
)

def withPolicyOpt(newPolicy: => Option[Policy]): Split =
if (isIgnored) this else newPolicy.fold(this)(withPolicy(_))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ object PolicyOps {
expire: T,
exclude: TokenRanges = TokenRanges.empty,
okSLC: Boolean = false,
noSyntaxNL: Boolean = false
noSyntaxNL: Boolean = false,
rank: Int = 0
)(implicit fileLine: FileLine): Policy =
policyWithExclude(exclude, Policy.End.On, Policy.End.After)(
Policy.End.On(expire),
new SingleLineBlock(_, okSLC = okSLC, noSyntaxNL = noSyntaxNL)
new SingleLineBlock(
_,
okSLC = okSLC,
noSyntaxNL = noSyntaxNL,
rank = rank
)
)
}

Expand Down

0 comments on commit 4801dec

Please sign in to comment.