Skip to content

SI-3368 CDATA gets a Node#4306

Merged
adriaanm merged 4 commits intoscala:2.11.xfrom
som-snytt:issue/3368-b
Apr 10, 2015
Merged

SI-3368 CDATA gets a Node#4306
adriaanm merged 4 commits intoscala:2.11.xfrom
som-snytt:issue/3368-b

Conversation

@som-snytt
Copy link
Contributor

XML Parser uses scala.xml.PCData.

A compiler flag -Yxml:coalescing, analogous to
DocumentBuilderFactory.setCoalescing, turns PCData
nodes into Text nodes and coalesces sibling text nodes.

This change also fixes parse errors such as rejecting a
sequence of CDATA sections.

A sequence of "top level" nodes is not coalesced.

scala> <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a>
res0: scala.xml.Elem = <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a>

scala> :replay -Yxml:coalescing
Replaying: <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a>
res0: scala.xml.Elem = <a><b/>starthi &amp; bye<c/>world<d/>stuffred &amp; black</a>

@scala-jenkins scala-jenkins added this to the 2.11.6 milestone Feb 10, 2015
@adriaanm adriaanm modified the milestones: 2.11.6, 2.11.7 Feb 19, 2015
@adriaanm
Copy link
Contributor

Since the 2.11.6 deadline is extremely nigh, I've tentatively postponed this PR (along with other recent ones) to 2.11.7. I'll make a pass through reviewed 2.11.7 PRs on Friday and move them back to 2.11.6 where feasible.

In the mean time, feel free to let me know if you'd like some help getting this reviewed by then.

Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to have a help text here, like we do in -language

@lrytz
Copy link
Member

lrytz commented Mar 24, 2015

looks great! just the few minor things mentioned above.

@som-snytt
Copy link
Contributor Author

@lrytz Thx! I'll break out the can of polish.

@som-snytt som-snytt closed this Mar 25, 2015
XML Parser uses `scala.xml.PCData`.

A compiler flag `-Yxml:coalescing`, analogous to
`DocumentBuilderFactory.setCoalescing`, turns `PCData`
nodes into `Text` nodes and coalesces sibling text nodes.

This change also fixes parse errors such as rejecting a
sequence of CDATA sections.

A sequence of "top level" nodes are not coalesced.

```
scala> <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a>
res0: scala.xml.Elem = <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a>

scala> :replay -Yxml:coalescing
Replaying: <a><b/>start<![CDATA[hi & bye]]><c/>world<d/>stuff<![CDATA[red & black]]></a>
res0: scala.xml.Elem = <a><b/>starthi &amp; bye<c/>world<d/>stuffred &amp; black</a>
```
Update the test slightly to use the rig it inspired.
As long as Scala does XML literals, there is probably parsing
behavior worth configuring.

Therefore, the umbrella option is promoted to `-Xxml`.

It was tempting to make it `-XML`, but we resisted.
@som-snytt
Copy link
Contributor Author

Rebased, so it lost previous greenies.

@adriaanm
Copy link
Contributor

adriaanm commented Apr 8, 2015

The (non-deterministic?) fail in b60de05 seems to imply we regressed somewhere (in the pattern matcher) -- diagnosing! Sorry about loss of green. Rebuilding to see whether it's stubborn.

@adriaanm
Copy link
Contributor

adriaanm commented Apr 8, 2015

ff2c0bb seems to have a legit fail, though:

fail - run/t5699.scala  [output differs]% scalac t5699.scala
% /usr/lib/jvm/jdk1.6.0_45/jre/bin/java \
  -Dfile.encoding=UTF-8 \
  -server \
  -XX:+AggressiveOpts \
  -XX:+UseParNewGC \
  -Xmx2G \
  -Xss1M \
  -XX:MaxPermSize=512M \
  -XX:ReservedCodeCacheSize=128M \
  -Dpartest.threads=4 \
  -classpath \
  /home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run/t5699-run.obj:/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-library.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-reflect.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-compiler.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scalap.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-actors.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/m2repo/org/scala-lang/modules/scala-partest_2.11/1.0.6/scala-partest_2.11-1.0.6.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/m2repo/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/m2repo/org/scala-sbt/test-interface/1.0/test-interface-1.0.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/m2repo/org/scala-lang/modules/scala-xml_2.11/1.0.3/scala-xml_2.11-1.0.3.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/m2repo/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.3/scala-parser-combinators_2.11-1.0.3.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/m2repo/org/scalacheck/scalacheck_2.11/1.11.4/scalacheck_2.11-1.11.4.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-partest-extras.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-partest-javaagent.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/lib/annotations.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/lib/enums.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/lib/genericNest.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/lib/jsoup-1.3.1.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/lib/macro210.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/lib/methvsfield.jar:/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/lib/nest.jar \
  -Dfile.encoding=UTF-8 \
  -Djava.library.path=/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run \
  -Dpartest.output=/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run/t5699-run.obj \
  -Dpartest.lib=/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-library.jar \
  -Dpartest.reflect=/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-reflect.jar \
  -Dpartest.comp=/home/jenkins/workspace/scala-2.11.x-validate-test/build/pack/lib/scala-compiler.jar \
  -Dpartest.cwd=/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run \
  -Dpartest.test-path=/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run/t5699.scala \
  -Dpartest.testname=t5699 \
  -Djavacmd=/usr/lib/jvm/jdk1.6.0_45/jre/bin/java \
  -Djavaccmd=javac \
  -Duser.language=en \
  -Duser.country=US \
  scala.tools.nsc.MainGenericRunner \
  -usejavacp \
  Test \
  jvm > t5699-run.log
% diff /home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run/t5699-run.log /home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run/t5699.check
--- a/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run/t5699-run.log
+++ b/home/jenkins/workspace/scala-2.11.x-validate-test/test/files/run/t5699.check
@@ -1,3 +1,11 @@
 [[syntax trees at end of                    parser]] // annodef.java
-<empty>
+package <empty> {
+  object MyAnnotation extends  {
+    def <init>() = _
+  };
+  class MyAnnotation extends scala.annotation.Annotation with _root_.java.lang.annotation.Annotation with scala.annotation.ClassfileAnnotation {
+    def <init>() = _;
+    def value(): String
+  }
+}

@som-snytt
Copy link
Contributor Author

I just commented above (outdatedly):

Owner
lrytz added a note 16 days ago

also redundant now
@som-snytt
som-snytt added a note 3 hours ago

It will stop after parser; assume it would proceed successfully thru typer.
@som-snytt
som-snytt added a note 8 minutes ago

Or, maybe it won't print anything and fail the test.

@som-snytt
Copy link
Contributor Author

OK, next theory, the prodigal test is compiling Java code. How does that interact with phasing? he asked himself.

I left the test overriding extra settings with -Ystop-after:namer. I came close to -Ystop-before:packageobjects because neither stop-before nor packageobjects get enough attention.

Verbose option help and test tweak.
@som-snytt
Copy link
Contributor Author

/rebuild

@adriaanm
Copy link
Contributor

Let's :shipit: 🚀 ✨ :so_much_emoji_everywhere!:

adriaanm added a commit that referenced this pull request Apr 10, 2015
@adriaanm adriaanm merged commit 3cf7c95 into scala:2.11.x Apr 10, 2015
@som-snytt som-snytt deleted the issue/3368-b branch April 12, 2015 21:40
@adriaanm
Copy link
Contributor

@som-snytt
Copy link
Contributor Author

I'll take a look. I guess it doesn't community-build per commit yet.

@adriaanm
Copy link
Contributor

Thank you! Unfortunately, this wasn't caught until late at night (in some timezone anyway).

@som-snytt
Copy link
Contributor Author

I commented on the other ticket that presumably -Xxml:coalescing should default for 2.11.x. With a dash of -Xfuture.

Or, possibly, the previous behavior was just a bug, and the only people using scala-xml are the only people who want this feature to default to the correct behavior.

@adriaanm
Copy link
Contributor

I unfortunately can't speak for one or the other, knowing nothing of xml's knotty gritty except that it was one of Scala's hippest features at one point.

@som-snytt
Copy link
Contributor Author

I saw the slide show. OK, I'll re-open this ticket to preserve behavior, and add an issue to change it in 2.12.

@adriaanm
Copy link
Contributor

Much obliged </.>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants