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; }
public boolean visit(Statement e) throws Exception { if (typeDeclaration.sourceStart() < e.sourceStart() && typeDeclaration.sourceEnd() > e.sourceEnd()) { if (e instanceof PHPFieldDeclaration) { PHPFieldDeclaration phpFieldDecl = (PHPFieldDeclaration) e; if (phpFieldDecl.getDeclarationStart() == offset && phpFieldDecl.sourceEnd() - phpFieldDecl.getDeclarationStart() == length) { result = ((PHPFieldDeclaration) e).getVariableValue(); if (result instanceof Scalar) { Scalar scalar = (Scalar) result; if (scalar.getScalarType() == Scalar.TYPE_STRING && scalar.getValue().toLowerCase().equals(NULL)) { result = null; } } context = contextStack.peek(); } } } return visitGeneral(e); }
@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; }