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

Parameterize preprocessor behavior to allow mode overrides. #13

Merged
merged 14 commits into from
Oct 20, 2019

Conversation

sampottinger
Copy link
Collaborator

In response to processing#11, allow client code to override preprocessing edit behavior by providing a subclass of PdeParseTreeListener. Specifically, given the changes necessitated by #1's swtich to ANTLR 4, this PR formalizes the interfaces to parameterize that behavior and adjusts internal code to improve mode developer experience.

For a demonstration of this new interface (prepared for @codeanticode) please see https://gist.github.com/sampottinger/11c453f5f641d96b4244f947d93cca33.

Note that many of the small interfaces were refactored to keep consistent with @benfry's goal for low class count.

sampottinger and others added 9 commits October 10, 2019 08:36
In response to benfry#11, allow client code to override preprocessing edit behabior by providing a subclass of PdeParseTreeListener. This does make the construction for PdePreprocessor.java a little bit messier but a builder may help and moving dependent types within enclosing classes can hopefully keep things coherent.
Some difficult to generate code is managed by the RewriterCodeGenerator and some modes may need to modify that logic. This commit makes it easier to extend parts of RewriterCodeGenerator without requiring client code to duplicate too much effort.
To support modes, allow for public instantiation of PdeParseTreeListener and for its public extension.
In support of modes, allow client code override of core and default imports for PdeParseTreeListener.
An explicit goal of @benfry is to reduce class count and this PR cleans up edits made within preproc to merge supporting classes and utility functions of PdeParseTreeListener into PdeParseTreeListener itself. This includes removal of ImportUtil per benfry#10.
@sampottinger sampottinger changed the title Parameterize preprocessor behavior to allow mode override. Parameterize preprocessor behavior to allow mode overrides. Oct 12, 2019
@sampottinger
Copy link
Collaborator Author

Hey @monkstone! Not 100% sure but this may be relevant to your work as well? See #11. Thanks!

@monkstone
Copy link
Contributor

@sampottinger Thanks for heads up, but I never tried to create a ruby mode for the Processing Ide @tyfkda did here. I have instead created an atom plugin.

Allow client code to provide a destination package for generated code and removed some (now dead) code for RewriterCodeGenerator.
@sampottinger
Copy link
Collaborator Author

Thanks for the clarification @monkstone

@sampottinger
Copy link
Collaborator Author

Quick thing: Trying to remove RewriteParams by rolling it into PdeParseTreeListener. Do not merge until I have a chance to do that.

Per @benfry goal of reducing class count, rolled RewriteParams into PdeParseTreeListener now that the code rewrite utils are also rolled into PdeParseTreeListener.
@sampottinger
Copy link
Collaborator Author

RewriteParams rolled into PdeParseTreeListener (per low class count target for project). Ok to merge again.

@codeanticode
Copy link
Collaborator

@sampottinger quick question, where is the ProcessingBaseListener base class that PdeParseTreeListener extends?

@codeanticode
Copy link
Collaborator

Never mind, I just realized it is generated during the build :-)

@sampottinger
Copy link
Collaborator Author

where is the ProcessingBaseListener base class that PdeParseTreeListener extends?

Hey @codeanticode! Thanks for following up. Just for progeny, you are correct about ProcessingBaseListener and it is part of the Listener pattern-based infrastructure of ANTLR 4 as described at https://github.com/antlr/antlr4/blob/master/doc/listeners.md.

@sampottinger
Copy link
Collaborator Author

Also @codeanticode, fdcaf7d addresses your request. It can be used like so:

PdePreprocessor.builderFor(sketchName)
        .setParseTreeListenerFactory(...)
        .setDestinationPackage("com.someone.somwhere")
        .build();

This should keep the ANTLR types from leaking out into modes unless they need to modify the edit behavior at a deeper level.

Thank you for your hard work. Please let me know if there is more that I can do.

Thanks,
Sam

@benfry benfry merged commit 85f300c into benfry:master Oct 20, 2019
benfry pushed a commit that referenced this pull request Nov 15, 2019
[Fork] Refactor within PdePreprocessor to allow for override of edits.
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants