-
-
Notifications
You must be signed in to change notification settings - Fork 901
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
(jruby) Fix Node#line #2177
Merged
Merged
(jruby) Fix Node#line #2177
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Note that Java's w3c.dom.Node interface does not have any way to get (or set) the line number for that node. The original JRuby implementation counted newlines, but did it poorly -- see #1223. This commit improves the newline-counting approach. But the solution itself -- counting newlines! -- is still questionable IMHO and absolutely inefficient. I had played around with an approach that I wrote about at #1223, where the SAX Parser knows what line it's on when `startElement` is invoked (via the XMLLocator). But I couldn't figure out how to preserve that information in the final Document or Node. If you, like me, think this approach is terrible; and if you *also* understand how to set this metadata on the Node or the Document, then please help us out.
This was referenced Mar 11, 2021
This was referenced Mar 18, 2021
flavorjones
added a commit
that referenced
this pull request
Aug 14, 2021
feat(cruby): support line numbers larger than a short --- **What problem is this PR intended to solve?** As noted in #1493, #1617, #1505, #1003, and #533, libxml2 has not historically supported line numbers greater than a `short int`. Starting in libxml v2.9.0, setting the parse option `BIG_LINES` would allow tracking line numbers in longer documents. Specifically this PR makes the following changes: - set `BIG_LINES` parse option by default which will allow `Node#line` to return large integers - allow `Node#line=` to set large line numbers on text nodes Fixes #1764 **Have you included adequate test coverage?** Yes! **Does this change affect the behavior of either the C or the Java implementations?** JRuby's Xerces-based implementation did not suffer from this particular shortcoming, although its line number functionality is questionable in other ways (see #2177 / b32c875).
This was referenced Dec 8, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is this PR intended to solve?
#1223 to make
Node#line
on JRuby smarter.For background, the Java DOM interfaces don't provide any way for a Node to know or find the line number in the original document at which it appeared.
I'm unhappy with this approach, but was unable to figure out how to make the original approach at #1223 work. If you're familiar with the Java DOM interfaces and want to help, please do.
Have you included adequate test coverage?
Yes.
Does this change affect the behavior of either the C or the Java implementations?
The Java implementation's behavior should be closer to the C implementation's behavior now.