/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public Result visitChildren(@NotNull RuleNode node) { Result result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); Result childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }