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

Allow state override #186

Merged
merged 2 commits into from
Oct 10, 2019
Merged

Allow state override #186

merged 2 commits into from
Oct 10, 2019

Conversation

mtdowling
Copy link
Member

Make CodeWriters intercept Object instead of String

This commit makes CodeWriter section interceptors deal with Object
instead of String. This allows for the toString() method of the
intercepted text to be wrapped by classes that extend from CodeWriter in
order to determine if any side effects from the original content should
take effect or be discarded. The general idea is that if toString() was
called on the original content of an intercepted section, then original
contents are also going to be written to the CodeWriter, meaning any
side effects should also occur (for example, adding imports).

Allow pushState and popState to be overridden

When extending CodeWriter, you might need to also track state like
imports in a corresponding stack. This is now possible since pushState
and popState can be overridden.

When extending CodeWriter, you might need to also track state like
imports in a corresponding stack. This is now possible since pushState
and popState can be overridden.
This commit makes CodeWriter section interceptors deal with Object
instead of String. This allows for the toString() method of the
intercepted text to be wrapped by classes that extend from CodeWriter in
order to determine if any side effects from the original content should
take effect or be discarded. The general idea is that if toString() was
called on the original content of an intercepted section, then original
contents are also going to be written to the CodeWriter, meaning any
side effects should also occur (for example, adding imports).
@mtdowling mtdowling requested a review from kstich October 10, 2019 20:36
@mtdowling mtdowling merged commit 2b47ab6 into master Oct 10, 2019
@mtdowling mtdowling deleted the allow-state-override branch October 15, 2019 20:10
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.

2 participants