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

FormatOps: move ExtractFromMeta to companion obj #4060

Merged
merged 1 commit into from
Jun 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ class FormatOps(
(arguments.toMap, optional.result())
}

class ExtractFromMeta[A](f: FormatToken.Meta => Option[A]) {
def unapply(meta: FormatToken.Meta): Option[A] = f(meta)
}

@inline
final def findFirst(start: FormatToken, end: T)(
f: FormatToken => Boolean,
Expand Down Expand Up @@ -319,16 +315,6 @@ class FormatOps(
if (r.is[T.LeftBrace]) SplitTag.OneArgPerLine.activateOnly(s)
else Decision.onlyNewlineSplits(s)

val WithTemplateOnLeft = new ExtractFromMeta(_.leftOwner match {
case lo: Stat.WithTemplate => Some(lo.templ)
case _ => None
})

val TemplateOnRight = new ExtractFromMeta(_.rightOwner match {
case ro: Template => Some(ro)
case _ => None
})

def templateCurlyFt(template: Template): Option[FormatToken] =
getStartOfTemplateBody(template).map(tokenBefore)

Expand Down Expand Up @@ -862,9 +848,6 @@ class FormatOps(
style.newlines.notBeforeImplicitParamListModifier &&
hasImplicitParamList(formatToken.meta.rightOwner)

val ImplicitUsingOnLeft =
new ExtractFromMeta(meta => getImplicitParamList(meta.leftOwner))

def isSingleIdentifierAnnotation(tok: FormatToken): Boolean = {
val toMatch =
if (tok.right.is[T.RightParen])
Expand Down Expand Up @@ -2876,4 +2859,21 @@ object FormatOps {
)
}

class ExtractFromMeta[A](f: FormatToken.Meta => Option[A]) {
def unapply(meta: FormatToken.Meta): Option[A] = f(meta)
}

val ImplicitUsingOnLeft =
new ExtractFromMeta(meta => TreeOps.getImplicitParamList(meta.leftOwner))

val WithTemplateOnLeft = new ExtractFromMeta(_.leftOwner match {
case lo: Stat.WithTemplate => Some(lo.templ)
case _ => None
})

val TemplateOnRight = new ExtractFromMeta(_.rightOwner match {
case ro: Template => Some(ro)
case _ => None
})

}
Loading