1 4 package com.tc.aspectwerkz.cflow; 5 6 7 import com.tc.aspectwerkz.expression.ast.*; 8 import com.tc.aspectwerkz.expression.ExpressionInfo; 9 import com.tc.aspectwerkz.expression.ExpressionNamespace; 10 11 import java.util.List ; 12 13 20 public class CflowAspectExpressionVisitor implements ExpressionParserVisitor { 21 22 private ExpressionInfo m_expressionInfo; 23 private Node m_root; 24 private String m_namespace; 25 26 public CflowAspectExpressionVisitor(ExpressionInfo expressionInfo, Node root, String namespace) { 27 m_expressionInfo = expressionInfo; 28 m_root = root; 29 m_namespace = namespace; 30 } 31 32 39 public List populateCflowAspectBindings(List bindings) { 40 visit(m_root, bindings); 41 return bindings; 42 } 43 44 public Object visit(Node node, Object data) { 45 return node.jjtGetChild(0).jjtAccept(this, data); 46 } 47 48 public Object visit(SimpleNode node, Object data) { 49 return node.jjtGetChild(0).jjtAccept(this, data); 50 } 51 52 public Object visit(ASTRoot node, Object data) { 53 return node.jjtGetChild(0).jjtAccept(this, data); 54 } 55 56 public Object visit(ASTExpression node, Object data) { 57 return node.jjtGetChild(0).jjtAccept(this, data); 58 } 59 60 public Object visit(ASTAnd node, Object data) { 61 for (int i = 0; i < node.jjtGetNumChildren(); i++) { 63 node.jjtGetChild(i).jjtAccept(this, data); 64 } 65 return data; 66 } 67 68 public Object visit(ASTOr node, Object data) { 69 for (int i = 0; i < node.jjtGetNumChildren(); i++) { 71 node.jjtGetChild(i).jjtAccept(this, data); 72 } 73 return data; 74 } 75 76 public Object visit(ASTNot node, Object data) { 77 return node.jjtGetChild(0).jjtAccept(this, data); 78 } 79 80 87 public Object visit(ASTPointcutReference node, Object data) { 88 ExpressionNamespace namespace = ExpressionNamespace.getNamespace(m_namespace); 89 CflowAspectExpressionVisitor expression = namespace.getExpressionInfo(node.getName()).getCflowAspectExpression(); 90 return expression.populateCflowAspectBindings((List ) data); 91 } 92 93 public Object visit(ASTExecution node, Object data) { 94 return data; 95 } 96 97 public Object visit(ASTCall node, Object data) { 98 return data; 99 } 100 101 public Object visit(ASTSet node, Object data) { 102 return data; 103 } 104 105 public Object visit(ASTGet node, Object data) { 106 return data; 107 } 108 109 public Object visit(ASTHandler node, Object data) { 110 return data; 111 } 112 113 public Object visit(ASTWithin node, Object data) { 114 return data; 115 } 116 117 public Object visit(ASTWithinCode node, Object data) { 118 return data; 119 } 120 121 public Object visit(ASTStaticInitialization node, Object data) { 122 return data; 123 } 124 125 public Object visit(ASTIf node, Object data) { 126 return data; 127 } 128 129 136 public Object visit(ASTCflow node, Object data) { 137 int cflowID = node.hashCode(); 138 Node subNode = node.jjtGetChild(0); 139 ExpressionInfo subExpression = new ExpressionInfo(subNode, m_namespace); 140 subExpression.inheritPossibleArgumentFrom(m_expressionInfo); 141 ((List ) data).add(new CflowBinding(cflowID, subExpression, m_expressionInfo, false)); 142 return data; 143 } 144 145 152 public Object visit(ASTCflowBelow node, Object data) { 153 int cflowID = node.hashCode(); 154 Node subNode = node.jjtGetChild(0); 155 ExpressionInfo subExpression = new ExpressionInfo(subNode, m_namespace); 156 subExpression.inheritPossibleArgumentFrom(m_expressionInfo); 157 ((List ) data).add(new CflowBinding(cflowID, subExpression, m_expressionInfo, true)); 158 return data; 159 } 160 161 public Object visit(ASTArgs node, Object data) { 162 return data; 163 } 164 165 public Object visit(ASTHasMethod node, Object data) { 166 return data; 167 } 168 169 public Object visit(ASTHasField node, Object data) { 170 return data; 171 } 172 173 public Object visit(ASTTarget node, Object data) { 174 return data; 175 } 176 177 public Object visit(ASTThis node, Object data) { 178 return data; 179 } 180 181 public Object visit(ASTClassPattern node, Object data) { 182 throw new UnsupportedOperationException ("Should not be reached"); 183 } 184 185 public Object visit(ASTMethodPattern node, Object data) { 186 throw new UnsupportedOperationException ("Should not be reached"); 187 } 188 189 public Object visit(ASTConstructorPattern node, Object data) { 190 throw new UnsupportedOperationException ("Should not be reached"); 191 } 192 193 public Object visit(ASTFieldPattern node, Object data) { 194 throw new UnsupportedOperationException ("Should not be reached"); 195 } 196 197 public Object visit(ASTParameter node, Object data) { 198 throw new UnsupportedOperationException ("Should not be reached"); 199 } 200 201 public Object visit(ASTArgParameter node, Object data) { 202 throw new UnsupportedOperationException ("Should not be reached"); 203 } 204 205 public Object visit(ASTAttribute node, Object data) { 206 throw new UnsupportedOperationException ("Should not be reached"); 207 } 208 209 public Object visit(ASTModifier node, Object data) { 210 throw new UnsupportedOperationException ("Should not be reached"); 211 } 212 } 213 | Popular Tags |