@Override public boolean visit(Statement s) throws Exception { if (!inTagParseMethod) return false; s.traverse( new PHPASTVisitor() { @Override public boolean visit(PHPCallExpression callExpr) throws Exception { SimpleReference ref = callExpr.getCallName(); if (ref != null && TwigCoreConstants.PARSE_SUB.equals(ref.getName())) { callExpr.traverse( new PHPASTVisitor() { @Override public boolean visit(ArrayCreation array) throws Exception { for (ArrayElement elem : array.getElements()) { Expression value = elem.getValue(); if (value == null) continue; if (value.getClass() == Scalar.class) { Scalar scalar = (Scalar) value; String subParseMethod = scalar.getValue().replaceAll("['\"]", ""); for (MethodDeclaration method : currentClass.getMethods()) { if (subParseMethod.equals(method.getName())) { String[] endStatements = TwigModelUtils.getEndStatements((PHPMethodDeclaration) method); for (String stmt : endStatements) { if (stmt.startsWith("end")) { tag.setEndTag(stmt); return false; } } } } } } return true; } }); } return true; } }); return true; }
public boolean visit(IfStatement s) throws Exception { Map<String, String> parameters = createInitialParameters(s); xmlWriter.startTag("IfStatement", parameters); xmlWriter.startTag("Condition", new HashMap<String, String>()); s.getCondition().traverse(this); xmlWriter.endTag("Condition"); xmlWriter.startTag("TrueStatement", new HashMap<String, String>()); s.getTrueStatement().traverse(this); xmlWriter.endTag("TrueStatement"); Statement falseStatement = s.getFalseStatement(); if (falseStatement != null) { xmlWriter.startTag("FalseStatement", new HashMap<String, String>()); falseStatement.traverse(this); xmlWriter.endTag("FalseStatement"); } return false; }