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