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

Parse nodes before and after the root element #560

Merged
merged 1 commit into from
Dec 13, 2021
Merged

Parse nodes before and after the root element #560

merged 1 commit into from
Dec 13, 2021

Conversation

dubinsky
Copy link
Contributor

@dubinsky dubinsky commented Sep 10, 2021

@ashawley @SethTisue yet another bit of the lexical stuff

XML allows for comments and processing instructions to be present before the start and after the end of the root element. Currently, FactoryAdapter does not capture those nodes, and XMLLoader.loadXML does not provide access to anything other than the root element anyway. This pull request addresses the issue.

Note: at least with the JDK's Xerces, whitespace in the prolog and epilogue gets lost in parsing: the parser does not fire any white-space related events.

(Travis builds for JDK 17 fail with "no matching JDK found: 17" as noted in #559.)

@dubinsky dubinsky marked this pull request as ready for review September 10, 2021 20:19
@ashawley
Copy link
Member

There's a lot of syntax fixes in this patch in files unrelated to the node parsing change. Is there a way to minimize this change so it can be reviewed easier?

@dubinsky
Copy link
Contributor Author

dubinsky commented Sep 13, 2021

Is there a way to minimize this change so it can be reviewed easier?

@ashawley done:

  • semicolons dating from the time when this was (probably) re-written from Java restored ;)
  • explicit types (in files unrelated to the node parsing change) removed;
  • explicit override annotations removed, but not the note about a potentially problematic override situation that was discovered as the result of annotating the overrides.

Is this acceptable or should I minimize the patch some more?

Thanks!!!

@SethTisue
Copy link
Member

(We're happy to have the code cleanups, if you still want to include them -- just in a separate commit from the main changes.)

@ashawley
Copy link
Member

Yeah, I had no objection to the code cleanup, it is much needed. There was just a lot here. It's more ideal if bulk code cleanup were made separately in another PR.

@dubinsky
Copy link
Contributor Author

Yeah, I had no objection to the code cleanup, it is much needed. There was just a lot here. It's more ideal if bulk code cleanup were made separately in another PR.

Cool. I agree that code cleanup should be done systematically, thoroughly and in bulk. But then there will be even more there ;)
Let's deal with the change at hand, then with #506 - and then maybe...

Thanks!

@dubinsky
Copy link
Contributor Author

dubinsky commented Oct 1, 2021

@ashawley Is there anything I need to change in this pull request for it to get merged? Thanks!

@SethTisue
Copy link
Member

SethTisue commented Oct 1, 2021

@dubinsky (this doesn't answer your question, but:) mind rebasing onto current main so we get GitHub Actions runs instead of Travis-CI?

…ore the start and after the end of the root element. Currently, `FactoryAdapter` does not capture those nodes, and `XMLLoader.loadXML` does not provide access to anything other than the root element anyway.

This pull request addresses the issue.

Note: at least with the JDK's Xerces, whitespace in the prolog and epilogue gets lost in parsing: the parser does not fire any white-space related events.
@dubinsky
Copy link
Contributor Author

dubinsky commented Oct 1, 2021

mind rebasing onto current main so we get GitHub Actions runs instead of Travis-CI?

@SethTisue done

@dubinsky
Copy link
Contributor Author

dubinsky commented Oct 6, 2021

@ashawley @SethTisue Is there anything I need to change in this pull request for it to get merged? Thanks!

@@ -98,6 +98,8 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
var extIndex = -1

/** holds temporary values of pos */
// Note: this is clearly an override, but if marked as such it causes a "...cannot override a mutable variable"
// error with Scala 3; does it work with Scala 3 if not explicitly marked as an override remains to be seen...
Copy link
Member

Choose a reason for hiding this comment

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

looks like scala/scala3#13744 should fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yay! Thank you, I did not see that!

@dubinsky
Copy link
Contributor Author

@ashawley @SethTisue Is there anything I need to change in this pull request for it to get merged? Thanks!

@SethTisue
Copy link
Member

ping @ashawley — shall we just merge this?

@ashawley
Copy link
Member

Yes, I think we should merge. I actually have a few amendments to the API choices in this around naming, but I can try to suggest those in a followup PR. I think the code for accepting and capturing any pre-processing elements or comments and such is something we should get working, regardless.

@SethTisue SethTisue merged commit 1af1168 into scala:main Dec 13, 2021
@dubinsky
Copy link
Contributor Author

Thanks!

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.

3 participants