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 token parameterisation with multiple parameters #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

homedirectory
Copy link

I found the lack of specifying multiple distinct parameters to a token limiting. For example:

derive(Var).to(token.with(String.class, Integer.class))

This corrects the generation of variable names corresponding to terminal
parameters, such as Class or Enum.
Previous implementation could erronously generate code such as:
`java.lang.Enum enum = ...;` or `Type method(Class class)`
AST visitor generation was producing visitors that were hardly useful:
1. `visit` methods were final which prevented implementations from
   controlling the descending behaviour
2. `whileVisiting` methods were hardly useful due to point 1

Consider the task of wrapping a parent AST node in parentheses,
including its children. This could not be achieved using previous AST
visitors.

This change makes visitors be generated in the fashion of
javax.lang.model.util.ElementScanner. It allows implementations to
control the descent like so:

void visit(ParentNode node) {
    print("("); // before visiting children
    Visitor.super.visit(node); // descend
    print(")"); // after having visited children
}
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.

1 participant