View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.vm.rule;
5   
6   import java.util.List;
7   
8   import net.sourceforge.pmd.RuleContext;
9   import net.sourceforge.pmd.lang.Language;
10  import net.sourceforge.pmd.lang.ast.Node;
11  import net.sourceforge.pmd.lang.rule.AbstractRule;
12  import net.sourceforge.pmd.lang.rule.ImmutableLanguage;
13  import net.sourceforge.pmd.lang.vm.ast.ASTAddNode;
14  import net.sourceforge.pmd.lang.vm.ast.ASTAndNode;
15  import net.sourceforge.pmd.lang.vm.ast.ASTAssignment;
16  import net.sourceforge.pmd.lang.vm.ast.ASTBlock;
17  import net.sourceforge.pmd.lang.vm.ast.ASTComment;
18  import net.sourceforge.pmd.lang.vm.ast.ASTDirective;
19  import net.sourceforge.pmd.lang.vm.ast.ASTDivNode;
20  import net.sourceforge.pmd.lang.vm.ast.ASTEQNode;
21  import net.sourceforge.pmd.lang.vm.ast.ASTElseIfStatement;
22  import net.sourceforge.pmd.lang.vm.ast.ASTElseStatement;
23  import net.sourceforge.pmd.lang.vm.ast.ASTEscape;
24  import net.sourceforge.pmd.lang.vm.ast.ASTEscapedDirective;
25  import net.sourceforge.pmd.lang.vm.ast.ASTExpression;
26  import net.sourceforge.pmd.lang.vm.ast.ASTFalse;
27  import net.sourceforge.pmd.lang.vm.ast.ASTFloatingPointLiteral;
28  import net.sourceforge.pmd.lang.vm.ast.ASTForeachStatement;
29  import net.sourceforge.pmd.lang.vm.ast.ASTGENode;
30  import net.sourceforge.pmd.lang.vm.ast.ASTGTNode;
31  import net.sourceforge.pmd.lang.vm.ast.ASTIdentifier;
32  import net.sourceforge.pmd.lang.vm.ast.ASTIfStatement;
33  import net.sourceforge.pmd.lang.vm.ast.ASTIndex;
34  import net.sourceforge.pmd.lang.vm.ast.ASTIntegerLiteral;
35  import net.sourceforge.pmd.lang.vm.ast.ASTIntegerRange;
36  import net.sourceforge.pmd.lang.vm.ast.ASTLENode;
37  import net.sourceforge.pmd.lang.vm.ast.ASTLTNode;
38  import net.sourceforge.pmd.lang.vm.ast.ASTMap;
39  import net.sourceforge.pmd.lang.vm.ast.ASTMethod;
40  import net.sourceforge.pmd.lang.vm.ast.ASTModNode;
41  import net.sourceforge.pmd.lang.vm.ast.ASTMulNode;
42  import net.sourceforge.pmd.lang.vm.ast.ASTNENode;
43  import net.sourceforge.pmd.lang.vm.ast.ASTNotNode;
44  import net.sourceforge.pmd.lang.vm.ast.ASTObjectArray;
45  import net.sourceforge.pmd.lang.vm.ast.ASTOrNode;
46  import net.sourceforge.pmd.lang.vm.ast.ASTReference;
47  import net.sourceforge.pmd.lang.vm.ast.ASTSetDirective;
48  import net.sourceforge.pmd.lang.vm.ast.ASTStringLiteral;
49  import net.sourceforge.pmd.lang.vm.ast.ASTSubtractNode;
50  import net.sourceforge.pmd.lang.vm.ast.ASTText;
51  import net.sourceforge.pmd.lang.vm.ast.ASTTextblock;
52  import net.sourceforge.pmd.lang.vm.ast.ASTTrue;
53  import net.sourceforge.pmd.lang.vm.ast.ASTWord;
54  import net.sourceforge.pmd.lang.vm.ast.ASTprocess;
55  import net.sourceforge.pmd.lang.vm.ast.VmNode;
56  import net.sourceforge.pmd.lang.vm.ast.VmParserVisitor;
57  
58  public abstract class AbstractVmRule extends AbstractRule implements VmParserVisitor, ImmutableLanguage {
59  
60      public AbstractVmRule() {
61          super.setLanguage(Language.VM);
62      }
63  
64      @Override
65      public void setUsesTypeResolution() {
66          // No Type resolution for Velocity rules?
67      }
68  
69      @Override
70      public void apply(final List<? extends Node> nodes, final RuleContext ctx) {
71          visitAll(nodes, ctx);
72      }
73  
74      protected void visitAll(final List<? extends Node> nodes, final RuleContext ctx) {
75          for (final Object element : nodes) {
76              final ASTprocess node = (ASTprocess) element;
77              visit(node, ctx);
78          }
79      }
80  
81      @Override
82      public Object visit(final VmNode node, final Object data) {
83          node.childrenAccept(this, data);
84          return null;
85      }
86  
87      @Override
88      public Object visit(final ASTprocess node, final Object data) {
89          return visit((VmNode) node, data);
90      }
91  
92      @Override
93      public Object visit(final ASTEscapedDirective node, final Object data) {
94          return visit((VmNode) node, data);
95      }
96  
97      @Override
98      public Object visit(final ASTEscape node, final Object data) {
99          return visit((VmNode) node, data);
100     }
101 
102     @Override
103     public Object visit(final ASTComment node, final Object data) {
104         return visit((VmNode) node, data);
105     }
106 
107     @Override
108     public Object visit(final ASTTextblock node, final Object data) {
109         return visit((VmNode) node, data);
110     }
111 
112     @Override
113     public Object visit(final ASTFloatingPointLiteral node, final Object data) {
114         return visit((VmNode) node, data);
115     }
116 
117     @Override
118     public Object visit(final ASTIntegerLiteral node, final Object data) {
119         return visit((VmNode) node, data);
120     }
121 
122     @Override
123     public Object visit(final ASTStringLiteral node, final Object data) {
124         return visit((VmNode) node, data);
125     }
126 
127     @Override
128     public Object visit(final ASTIdentifier node, final Object data) {
129 
130         return visit((VmNode) node, data);
131     }
132 
133     @Override
134     public Object visit(final ASTWord node, final Object data) {
135 
136         return visit((VmNode) node, data);
137     }
138 
139     @Override
140     public Object visit(final ASTDirective node, final Object data) {
141 
142         return visit((VmNode) node, data);
143     }
144 
145     @Override
146     public Object visit(final ASTBlock node, final Object data) {
147 
148         return visit((VmNode) node, data);
149     }
150 
151     @Override
152     public Object visit(final ASTMap node, final Object data) {
153 
154         return visit((VmNode) node, data);
155     }
156 
157     @Override
158     public Object visit(final ASTObjectArray node, final Object data) {
159 
160         return visit((VmNode) node, data);
161     }
162 
163     @Override
164     public Object visit(final ASTIntegerRange node, final Object data) {
165 
166         return visit((VmNode) node, data);
167     }
168 
169     @Override
170     public Object visit(final ASTMethod node, final Object data) {
171 
172         return visit((VmNode) node, data);
173     }
174 
175     @Override
176     public Object visit(final ASTIndex node, final Object data) {
177 
178         return visit((VmNode) node, data);
179     }
180 
181     @Override
182     public Object visit(final ASTReference node, final Object data) {
183 
184         return visit((VmNode) node, data);
185     }
186 
187     @Override
188     public Object visit(final ASTTrue node, final Object data) {
189 
190         return visit((VmNode) node, data);
191     }
192 
193     @Override
194     public Object visit(final ASTFalse node, final Object data) {
195 
196         return visit((VmNode) node, data);
197     }
198 
199     @Override
200     public Object visit(final ASTText node, final Object data) {
201 
202         return visit((VmNode) node, data);
203     }
204 
205     @Override
206     public Object visit(final ASTForeachStatement node, final Object data) {
207 
208         return visit((VmNode) node, data);
209     }
210 
211     @Override
212     public Object visit(final ASTIfStatement node, final Object data) {
213 
214         return visit((VmNode) node, data);
215     }
216 
217     @Override
218     public Object visit(final ASTElseStatement node, final Object data) {
219 
220         return visit((VmNode) node, data);
221     }
222 
223     @Override
224     public Object visit(final ASTElseIfStatement node, final Object data) {
225 
226         return visit((VmNode) node, data);
227     }
228 
229     @Override
230     public Object visit(final ASTSetDirective node, final Object data) {
231 
232         return visit((VmNode) node, data);
233     }
234 
235     @Override
236     public Object visit(final ASTExpression node, final Object data) {
237 
238         return visit((VmNode) node, data);
239     }
240 
241     @Override
242     public Object visit(final ASTAssignment node, final Object data) {
243 
244         return visit((VmNode) node, data);
245     }
246 
247     @Override
248     public Object visit(final ASTOrNode node, final Object data) {
249 
250         return visit((VmNode) node, data);
251     }
252 
253     @Override
254     public Object visit(final ASTAndNode node, final Object data) {
255 
256         return visit((VmNode) node, data);
257     }
258 
259     @Override
260     public Object visit(final ASTEQNode node, final Object data) {
261 
262         return visit((VmNode) node, data);
263     }
264 
265     @Override
266     public Object visit(final ASTNENode node, final Object data) {
267 
268         return visit((VmNode) node, data);
269     }
270 
271     @Override
272     public Object visit(final ASTLTNode node, final Object data) {
273 
274         return visit((VmNode) node, data);
275     }
276 
277     @Override
278     public Object visit(final ASTGTNode node, final Object data) {
279 
280         return visit((VmNode) node, data);
281     }
282 
283     @Override
284     public Object visit(final ASTLENode node, final Object data) {
285 
286         return visit((VmNode) node, data);
287     }
288 
289     @Override
290     public Object visit(final ASTGENode node, final Object data) {
291 
292         return visit((VmNode) node, data);
293     }
294 
295     @Override
296     public Object visit(final ASTAddNode node, final Object data) {
297 
298         return visit((VmNode) node, data);
299     }
300 
301     @Override
302     public Object visit(final ASTSubtractNode node, final Object data) {
303 
304         return visit((VmNode) node, data);
305     }
306 
307     @Override
308     public Object visit(final ASTMulNode node, final Object data) {
309 
310         return visit((VmNode) node, data);
311     }
312 
313     @Override
314     public Object visit(final ASTDivNode node, final Object data) {
315 
316         return visit((VmNode) node, data);
317     }
318 
319     @Override
320     public Object visit(final ASTModNode node, final Object data) {
321 
322         return visit((VmNode) node, data);
323     }
324 
325     @Override
326     public Object visit(final ASTNotNode node, final Object data) {
327 
328         return visit((VmNode) node, data);
329     }
330 
331 }