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

Refactor emission logic of SAXParser and RewritingStream #268

Merged
merged 6 commits into from Aug 10, 2018

Conversation

RReverser
Copy link
Collaborator

  • Fix SAXParser text end location (fixes Incorrect location info in SAXParser and RewritingStream #266).
  • Move lazy emission logic from RewritingStream::_handleToken to SAXParser::_handleToken. This allows SAXParser to skip reshaping when no listeners are registered and simplifies interaction between two APIs.
  • Make SAXParser::pendingText to keep a CHARACTER token instead of just chars. This aligns emission of pending text with other tokens and gives a single _emitToken point for RewritingStream to override (instead of additionally overriding _emitPendingText with similar logic).
  • Remove SAXParser::currentTokenLocation state, instead just retrieving location from current raw or processed token. It was needed mainly to track location for consequent text tokens, but since pendingText is now a token, it can store its own location internally. This additionally allows all reshapeToken helpers to become stateless and live outside of the class.

Now that location is retrieved directly from tokens, they no longer need to have access to `this` and can be just static helpers.
@RReverser RReverser requested a review from inikulin August 9, 2018 18:03
@RReverser RReverser merged commit 41a7f3f into master Aug 10, 2018
@RReverser RReverser deleted the saxparser-lazy-emit branch August 10, 2018 11:26
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.

Incorrect location info in SAXParser and RewritingStream
2 participants