Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Apr 3, 2022

When printing compiler ASTs with -Yprint, enable printing just the diff by -Yprint-trees:diff.

That is useful when you don't need to see the whole tree, but you want to see when some feature is introduced into the tree, or observe only the changes at a phase.

Now -Yprint-trees:help reports

Usage: -Yprint-trees:<style> where <style> choices are text, compact, format, text+format, diff (default: text).

What do those words mean? compact is Tree DSL style. format is less compact. text means sourcelike. text+format just outputs both styles. diff is just a text-based diff of the text style.

This PR also upgrades to the difflib the seems to have usurped the version from 2011.

We ought to embrace our differences. Vive la différence.

@scala-jenkins scala-jenkins added this to the 2.13.9 milestone Apr 3, 2022
@som-snytt som-snytt marked this pull request as draft April 3, 2022 19:36
@som-snytt som-snytt force-pushed the issues/12548-followup branch from bda56c4 to 7fe3dc9 Compare April 3, 2022 19:58
@som-snytt som-snytt marked this pull request as ready for review April 3, 2022 21:20
@lrytz
Copy link
Member

lrytz commented Apr 4, 2022

Oh nice! Seems to play well with ydiff

scpr 9987 Test.scala -Vprint:_ -Yprint-trees:diff | ydiff

image

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL -Yprint-trees exists. LGTM.

Copy link
Member

@SethTisue SethTisue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think much of a test suite is needed, but how about including one smoke test, just to make sure the feature doesn't stop working entirely in the future?

build.sbt Outdated
@@ -44,7 +44,8 @@ val jlineDep = "org.jline" % "jline"
val jnaDep = "net.java.dev.jna" % "jna" % versionProps("jna.version")
val jlineDeps = Seq(jlineDep, jnaDep)
val testInterfaceDep = "org.scala-sbt" % "test-interface" % "1.0"
val diffUtilsDep = "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
//val diffUtilsDep = "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(remove commented-out line)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, as usual, was afraid of losing visible info.

@@ -23,6 +23,7 @@ libraryDependencies ++= Seq(
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.11.9.201909030838-r",
"org.slf4j" % "slf4j-nop" % "1.7.36",
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
//"io.github.java-diff-utils" % "java-diff-utils" % "4.11",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I see the comment was for the new jar, and the question was, Is the other jar needed here for some reason?

Copy link
Contributor Author

@som-snytt som-snytt May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's used in build.sbt by the incredibly fragile scala/runtime patch for test/instrumented which should be renamed test/demented. I couldn't remove an import at some point in the past because of this mechanism. I'll try to understand what to do now. (That's what I meant above by "the build task". I guess there is no urgency in updating that detail of the build.)

@SethTisue
Copy link
Member

SethTisue commented Apr 20, 2022

Is there anywhere this could/should be documented?

At minimum, the PR should have a nice user-facing (meaning, compiler-hacker-facing) PR description, since this is where people'll land if they Google, if there isn't any other documentation.

@SethTisue
Copy link
Member

SethTisue commented Apr 20, 2022

Does the underlying library support ANSI color, by any chance? would be cool to have the red/green for old/new

above Lukas shows that ydiff can be used to supply that, but (fwiw) neither Dale and I knew ydiff existed

@SethTisue SethTisue added the internal not resulting in user-visible changes (build changes, tests, internal cleanups) label Apr 20, 2022
@SethTisue SethTisue changed the title -Yprint-trees:diff Add -Yprint-trees:diff to make -Vprint show diffs between phases Apr 20, 2022
@som-snytt
Copy link
Contributor Author

2 weeks ago I started to say TIL ydiff then got distracted, thanks @lrytz

@lrytz
Copy link
Member

lrytz commented Apr 20, 2022

I got to ydiff by wanting to ask about colored output, then googling etc.

@som-snytt
Copy link
Contributor Author

When Lukas pulls the curtain away from the man who stands behind it.

@SethTisue
Copy link
Member

@som-snytt mind improving the PR description before we merge?

@som-snytt
Copy link
Contributor Author

I will follow up the clean up items.

Also update the diff lib.
@som-snytt som-snytt force-pushed the issues/12548-followup branch from 7fe3dc9 to e792225 Compare May 10, 2022 15:09
@som-snytt
Copy link
Contributor Author

I was considering other print features, such as showing when synthetics are added, using synths-since.

Then we could say, Lukas has a sixth sense for synths since.

@SethTisue SethTisue added the release-notes worth highlighting in next release notes label May 12, 2022
@SethTisue SethTisue merged commit a051c92 into scala:2.13.x May 12, 2022
@som-snytt som-snytt deleted the issues/12548-followup branch May 12, 2022 14:51
@SethTisue SethTisue removed the release-notes worth highlighting in next release notes label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal not resulting in user-visible changes (build changes, tests, internal cleanups)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants