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

Update pprint to 0.8.1 #2724

Merged
merged 1 commit into from
Jun 10, 2023
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
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ lazy val `quill-engine` =
)
.jsSettings(
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "pprint" % "0.6.6",
"com.lihaoyi" %%% "pprint" % "0.8.1",
"io.github.cquiroz" %%% "scala-java-time" % "2.5.0",
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.2.0",
"io.suzaku" %%% "boopickle" % "1.4.0"
Expand Down Expand Up @@ -314,7 +314,7 @@ lazy val `quill-core` =
)
.jsSettings(
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "pprint" % "0.6.6"
"com.lihaoyi" %%% "pprint" % "0.8.1"
),
unmanagedSources / excludeFilter := new SimpleFileFilter(file => file.getName == "DynamicQuerySpec.scala"),
coverageExcludedPackages := ".*"
Expand Down Expand Up @@ -772,7 +772,7 @@ lazy val basicSettings = excludeFilterSettings ++ Seq(
scalaVersion := scala_v_13,
crossScalaVersions := Seq(scala_v_12, scala_v_13, scala_v_30),
libraryDependencies ++= Seq(
"com.lihaoyi" %% "pprint" % "0.6.6",
"com.lihaoyi" %% "pprint" % "0.8.1",
"org.scalatest" %%% "scalatest" % "3.2.16" % Test,
"com.google.code.findbugs" % "jsr305" % "3.0.2" % Provided // just to avoid warnings during compilation
) ++ {
Expand Down
24 changes: 12 additions & 12 deletions quill-engine/src/main/scala/io/getquill/AstPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class AstPrinter(traceOpinions: Boolean, traceAstSimple: Boolean, traceQuats: Qu
val defaultIndent: Int = 2
val colorLiteral: fansi.Attrs = fansi.Color.Green
val colorApplyPrefix: fansi.Attrs = fansi.Color.Yellow
def escapeUnicode = false
override def showFieldNames = false
val escapeUnicode = false
val showFieldNames = false

val traceAllQuats = traceQuats == QuatTrace.All

Expand Down Expand Up @@ -62,7 +62,7 @@ class AstPrinter(traceOpinions: Boolean, traceAstSimple: Boolean, traceQuats: Qu
case QuatTrace.Short => List(Tree.Literal(e.q.shortString.take(10)))
case QuatTrace.None => List()
}
case treemake.Elem(value) => List(treeify(value))
case treemake.Elem(value) => List(treeify(value, escapeUnicode, showFieldNames))
case treemake.Tree(value) => List(value)
case treemake.Content(list) => list.flatMap(_.treeifyList)
}
Expand All @@ -83,7 +83,7 @@ class AstPrinter(traceOpinions: Boolean, traceAstSimple: Boolean, traceQuats: Qu
def apply(list: Any*): treemake = Content(list.toList.map(Elem(_)))
}

override def treeify(x: Any): Tree =
override def treeify(x: Any, escapeUnicode: Boolean, showFieldNames: Boolean): Tree =
x match {
case ast: Ast if (traceAstSimple) =>
Tree.Literal("" + ast) // Do not blow up if it is null
Expand Down Expand Up @@ -119,7 +119,7 @@ class AstPrinter(traceOpinions: Boolean, traceAstSimple: Boolean, traceQuats: Qu
case p: Property if (traceOpinions) =>
TreeApplyList(
"Property",
l(treeify(p.ast)) ++ l(treeify(p.name)) ++
l(treeify(p.ast, escapeUnicode, showFieldNames)) ++ l(treeify(p.name, escapeUnicode, showFieldNames)) ++
(
if (traceOpinions)
l(printRenameable(p.renameable), printVisibility(p.visibility))
Expand All @@ -128,7 +128,7 @@ class AstPrinter(traceOpinions: Boolean, traceAstSimple: Boolean, traceQuats: Qu
) ++
(
if (traceAllQuats)
l(treeify(p.bestQuat))
l(treeify(p.bestQuat, escapeUnicode, showFieldNames))
else
List.empty[Tree]
)
Expand All @@ -142,26 +142,26 @@ class AstPrinter(traceOpinions: Boolean, traceAstSimple: Boolean, traceQuats: Qu

case ast: Ast =>
if (traceAllQuats)
super.treeify(ast) match {
super.treeify(ast, escapeUnicode, showFieldNames) match {
case Tree.Apply(prefix, body) =>
TreeApplyList(prefix, body.toList :+ treeify(ast.bestQuat))
TreeApplyList(prefix, body.toList :+ treeify(ast.bestQuat, escapeUnicode, showFieldNames))
case other => other
}
else
super.treeify(ast)
super.treeify(ast, escapeUnicode, showFieldNames)

case _ => super.treeify(x)
case _ => super.treeify(x, escapeUnicode, showFieldNames)
}

private def TreeApplyList(prefix: String, body: List[Tree]) = Tree.Apply(prefix, body.iterator)

private def l(trees: Tree*): List[Tree] = List[Tree](trees: _*)

def apply(x: Any): fansi.Str =
fansi.Str.join(this.tokenize(x).toSeq: _*)
fansi.Str.join(this.tokenize(x).toSeq)

def tokenize(x: Any): Iterator[fansi.Str] = {
val tree = this.treeify(x)
val tree = this.treeify(x, escapeUnicode, showFieldNames)
val renderer = new Renderer(defaultWidth, colorApplyPrefix, colorLiteral, defaultIndent)
val rendered = renderer.rec(tree, 0, 0).iter
val truncated = new Truncated(rendered, defaultWidth, defaultHeight)
Expand Down