mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Reformat with scalafmt 3.0.0
This commit is contained in:
@ -14,8 +14,7 @@ import docspell.query.ItemQuery.Expr.NotExpr
|
||||
import docspell.query.ItemQuery.Expr.OrExpr
|
||||
import docspell.query.ItemQuery._
|
||||
|
||||
/** Currently, fulltext in a query is only supported when in "root
|
||||
* AND" position
|
||||
/** Currently, fulltext in a query is only supported when in "root AND" position
|
||||
*/
|
||||
object FulltextExtract {
|
||||
|
||||
@ -45,15 +44,15 @@ object FulltextExtract {
|
||||
def findFulltext(expr: Expr): Result =
|
||||
lookForFulltext(expr)
|
||||
|
||||
/** Extracts the fulltext node from the given expr and returns it
|
||||
* together with the expr without that node.
|
||||
/** Extracts the fulltext node from the given expr and returns it together with the expr
|
||||
* without that node.
|
||||
*/
|
||||
private def lookForFulltext(expr: Expr): Result =
|
||||
expr match {
|
||||
case Expr.Fulltext(ftq) =>
|
||||
Result.SuccessNoExpr(ftq)
|
||||
case Expr.AndExpr(inner) =>
|
||||
inner.collect({ case Expr.Fulltext(fq) => fq }) match {
|
||||
inner.collect { case Expr.Fulltext(fq) => fq } match {
|
||||
case Nil =>
|
||||
checkPosition(expr, 0)
|
||||
case e :: Nil =>
|
||||
|
@ -10,12 +10,10 @@ import cats.data.{NonEmptyList => Nel}
|
||||
|
||||
import docspell.query.ItemQuery.Attr.{DateAttr, IntAttr, StringAttr}
|
||||
|
||||
/** A query evaluates to `true` or `false` given enough details about
|
||||
* an item.
|
||||
/** A query evaluates to `true` or `false` given enough details about an item.
|
||||
*
|
||||
* It may consist of (field,op,value) tuples that specify some checks
|
||||
* against a specific field of an item using some operator or a
|
||||
* combination thereof.
|
||||
* It may consist of (field,op,value) tuples that specify some checks against a specific
|
||||
* field of an item using some operator or a combination thereof.
|
||||
*/
|
||||
final case class ItemQuery(expr: ItemQuery.Expr, raw: Option[String]) {
|
||||
def findFulltext: FulltextExtract.Result =
|
||||
|
@ -45,7 +45,7 @@ object ParseFailure {
|
||||
def render: String = {
|
||||
val opts = expected.mkString(", ")
|
||||
val dots = if (exhaustive) "" else "…"
|
||||
s"Expected: ${opts}${dots}"
|
||||
s"Expected: $opts$dots"
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,11 +57,11 @@ object ParseFailure {
|
||||
)
|
||||
|
||||
private[query] def packMsg(msg: Nel[Message]): Nel[Message] = {
|
||||
val expectMsg = combineExpected(msg.collect({ case em: ExpectMessage => em }))
|
||||
val expectMsg = combineExpected(msg.collect { case em: ExpectMessage => em })
|
||||
.sortBy(_.offset)
|
||||
.headOption
|
||||
|
||||
val simpleMsg = msg.collect({ case sm: SimpleMessage => sm })
|
||||
val simpleMsg = msg.collect { case sm: SimpleMessage => sm }
|
||||
|
||||
Nel.fromListUnsafe((simpleMsg ++ expectMsg).sortBy(_.offset))
|
||||
}
|
||||
@ -69,13 +69,13 @@ object ParseFailure {
|
||||
private[query] def combineExpected(msg: List[ExpectMessage]): List[ExpectMessage] =
|
||||
msg
|
||||
.groupBy(_.offset)
|
||||
.map({ case (offset, es) =>
|
||||
.map { case (offset, es) =>
|
||||
ExpectMessage(
|
||||
offset,
|
||||
es.flatMap(_.expected).distinct.sorted,
|
||||
es.forall(_.exhaustive)
|
||||
)
|
||||
})
|
||||
}
|
||||
.toList
|
||||
|
||||
private[query] def expectationToMsg(e: Parser.Expectation): Message =
|
||||
@ -89,7 +89,7 @@ object ParseFailure {
|
||||
case InRange(offset, lower, upper) =>
|
||||
if (lower == upper) ExpectMessage(offset, List(lower.toString), true)
|
||||
else {
|
||||
val expect = s"${lower}-${upper}"
|
||||
val expect = s"$lower-$upper"
|
||||
ExpectMessage(offset, List(expect), true)
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,8 @@ import docspell.query.ItemQuery._
|
||||
|
||||
object ExprUtil {
|
||||
|
||||
/** Does some basic transformation, like unfolding nested and trees
|
||||
* containing one value etc.
|
||||
/** Does some basic transformation, like unfolding nested and trees containing one value
|
||||
* etc.
|
||||
*/
|
||||
def reduce(expr: Expr): Expr =
|
||||
expr match {
|
||||
|
Reference in New Issue
Block a user