C - subclass of this class to have functions returning this to have the correct typeN - base node type, this class does not care but in specific handlers it should be a common supertype for all nodesA - action type, subclasses of AstAction and AstHandler provide actual functionalityH - handler to invoke the functionality during AST traversal for specific nodepublic abstract class AstActionHandler<C extends AstActionHandler<C,N,A,H>,N,A extends AstAction<N>,H extends AstHandler<N,A>> extends Object
| Constructor and Description |
|---|
AstActionHandler(@NotNull AstNode<N> astAdapter) |
| Modifier and Type | Method and Description |
|---|---|
protected C |
addActionHandler(H handler) |
protected C |
addActionHandlers(H[]... handlers) |
A |
getAction(@NotNull Class<?> nodeClass) |
A |
getAction(N node) |
protected H |
getHandler(@NotNull Class<?> nodeClass) |
protected H |
getHandler(N node) |
@NotNull Set<Class<? extends N>> |
getNodeClasses() |
protected void |
processChildren(N node,
@NotNull BiConsumer<N,A> processor) |
protected void |
processNode(N node,
boolean withChildren,
@NotNull BiConsumer<N,A> processor)
Node processing called for every node being processed
|
protected <R> R |
processNodeOnly(N node,
R defaultValue,
@NotNull BiFunction<N,A,R> processor)
Process the node and return value from the processor
|
@SafeVarargs @NotNull protected final C addActionHandlers(@NotNull H[]... handlers)
protected void processNode(@NotNull
N node,
boolean withChildren,
@NotNull
@NotNull BiConsumer<N,A> processor)
Override this to add customizations to standard processing callback.
node - node being processedwithChildren - whether to process child nodes if there is no handler for the node typeprocessor - processor to invoke to perform the processing, BiConsumer taking N node, and A actionprotected final void processChildren(@NotNull
N node,
@NotNull
@NotNull BiConsumer<N,A> processor)
protected final <R> R processNodeOnly(@NotNull
N node,
R defaultValue,
@NotNull
@NotNull BiFunction<N,A,R> processor)
R - type of result returned by processornode - node to processdefaultValue - default value if no handler is defined for the nodeprocessor - processor to pass the node and handler for processingCopyright © 2020. All rights reserved.