public void accept(Visitor visitor) throws IOException, ParseException { if (visitor.visit(this)) { for (Node node : getChildren()) { node.accept(visitor); } } }
public int getOffset() { return root.getOffset(); }
private static String buildName(Resource resource, Node root) { StringBuilder builder = new StringBuilder(); builder.append(resource.getName()); while (root instanceof MacroDirective) { builder.append("#"); builder.append(((MacroDirective) root).getName()); root = root.getParent(); } return builder.toString(); }
public void accept(Visitor visitor) throws IOException, ParseException { if (visitor.visit(this)) { for (Node node : getChildren()) { node.accept(visitor); } } }
public int getOffset() { return root.getOffset(); }
private static String buildName(Resource resource, Node root) { StringBuilder builder = new StringBuilder(); builder.append(resource.getName()); while (root instanceof MacroDirective) { builder.append("#"); builder.append(((MacroDirective) root).getName()); root = root.getParent(); } return builder.toString(); }
@Override public void accept(Visitor visitor) throws IOException, ParseException { Expression expression = getExpression(); if (expression != null) expression.accept(visitor); if (visitor.visit(this)) { if (children != null) { for (Node node : children) { node.accept(visitor); } } if (end != null) end.accept(visitor); } }
public boolean visit(Node node) throws IOException, ParseException { try { if (node instanceof Expression) { visit((Expression) node); } else if (node instanceof Statement) { return visit((Statement) node); } else if (node instanceof Template) { return visit((Template) node); } } catch (IOException e) { throw e; } catch (ParseException e) { throw e; } catch (Exception e) { throw new ParseException(ClassUtils.toString(e), node.getOffset()); } return true; }
public void accept(Visitor visitor) throws IOException, ParseException { Expression expression = getExpression(); if (expression != null) { expression.accept(visitor); } if (visitor.visit(this)) { if (children != null) { for (Node node : children) { node.accept(visitor); } } if (end != null) { end.accept(visitor); } } }
public boolean visit(Node node) throws IOException, ParseException { try { if (node instanceof Expression) { visit((Expression) node); } else if (node instanceof Statement) { return visit((Statement) node); } else if (node instanceof Template) { return visit((Template) node); } } catch (IOException e) { throw e; } catch (ParseException e) { throw e; } catch (Exception e) { throw new ParseException(ClassUtils.toString(e), node.getOffset()); } return true; }
@Override public boolean visit(Template node) throws IOException, ParseException { for (Node child : node.getChildren()) { child.accept(this); if (ClassUtils.isTrue(Context.getContext().get(breakVariable))) { Context.getContext().remove(breakVariable); break; } } return false; }
@Override public boolean visit(Template node) throws IOException, ParseException { for (Node child : node.getChildren()) { child.accept(this); if (ClassUtils.isTrue(Context.getContext().get(breakVariable))) { Context.getContext().remove(breakVariable); break; } } return false; }
@Override public boolean visit(ForDirective node) throws IOException, ParseException { Object data = popExpressionResult(node.getOffset()); boolean result = ClassUtils.isTrue(data); Context.getContext().put(ifVariable, result); Iterator<?> iterator = CollectionUtils.toIterator(data); Status status = new Status((Status) Context.getContext().get(forVariable[0]), data); for (String var : forVariable) { Context.getContext().put(var, status); } loop: while (iterator.hasNext()) { Object item = iterator.next(); Context.getContext().put(node.getName(), item); for (Node child : node.getChildren()) { child.accept(this); if (ClassUtils.isTrue(Context.getContext().get(breakVariable))) { Context.getContext().remove(breakVariable); break loop; } } status.increment(); } for (String var : forVariable) { Context.getContext().put(var, status.getParent()); } return false; }
visitor.setCompiler(compiler); visitor.init(); root.accept(visitor); return visitor.compile();
@Override public boolean visit(ForDirective node) throws IOException, ParseException { Object data = popExpressionResult(node.getOffset()); boolean result = ClassUtils.isTrue(data); Context.getContext().put(ifVariable, result); Iterator<?> iterator = CollectionUtils.toIterator(data); Status status = new Status((Status) Context.getContext().get(forVariable[0]), data); for (String var : forVariable) { Context.getContext().put(var, status); } loop: while (iterator.hasNext()) { Object item = iterator.next(); Context.getContext().put(node.getName(), item); for (Node child : node.getChildren()) { child.accept(this); if (ClassUtils.isTrue(Context.getContext().get(breakVariable))) { Context.getContext().remove(breakVariable); break loop; } } status.increment(); } for (String var : forVariable) { Context.getContext().put(var, status.getParent()); } return false; }
visitor.setCompiler(compiler); visitor.init(); root.accept(visitor); return visitor.compile();
visitor.init(); for (Node n : node.getChildren()) { n.accept(visitor);
visitor.init(); for (Node n : node.getChildren()) { n.accept(visitor);