Skip to content

Allow token parameterisation with multiple parameters#25

Open
homedirectory wants to merge 3 commits intoOriRoth:masterfrom
homedirectory:token-multi-params
Open

Allow token parameterisation with multiple parameters#25
homedirectory wants to merge 3 commits intoOriRoth:masterfrom
homedirectory:token-multi-params

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