KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > cs > drjava > model > repl > IdentityVisitor


1 /*BEGIN_COPYRIGHT_BLOCK
2  *
3  * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
4  * or http://sourceforge.net/projects/drjava/
5  *
6  * DrJava Open Source License
7  *
8  * Copyright (C) 2001-2006 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
9  *
10  * Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13  * documentation files (the "Software"), to deal with the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15  * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16  *
17  * - Redistributions of source code must retain the above copyright notice, this list of conditions and the
18  * following disclaimers.
19  * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
20  * following disclaimers in the documentation and/or other materials provided with the distribution.
21  * - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
22  * endorse or promote products derived from this Software without specific prior written permission.
23  * - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
24  * names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
27  * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * WITH THE SOFTWARE.
31  *
32  *END_COPYRIGHT_BLOCK*/

33
34 package edu.rice.cs.drjava.model.repl;
35
36 import java.util.*;
37
38 import koala.dynamicjava.tree.*;
39 import koala.dynamicjava.tree.visitor.*;
40
41 /**
42  * This class visits each node and each node's members, recursively
43  * walking the syntax tree, returning the identical node back for
44  * each case. Note that Try, Catch, and ArrayAllocation statements
45  * return a new Node with the same fields because they did not appear
46  * to have all of the necessary setters.
47  *
48  * @version $Id: IdentityVisitor.java 3901 2006-06-30 05:28:11Z rcartwright $
49  */

50
51 public class IdentityVisitor implements Visitor<Node> {
52   /**
53    * Visits a PackageDeclaration
54    * @param node the node to visit
55    * @return node
56    */

57
58   public Node visit(PackageDeclaration node) { return node; }
59
60   /**
61    * Visits an ImportDeclaration
62    * @param node the node to visit
63    * @return node
64    */

65
66   public Node visit(ImportDeclaration node) { return node; }
67
68   /**
69    * Visits an EmptyStatement
70    * @param node the node to visit
71    */

72
73   public Node visit(EmptyStatement node) { return node; }
74
75   /**
76    * Visits a WhileStatement
77    * @param node the node to visit
78    */

79   public Node visit(WhileStatement node) {
80     node.setCondition((Expression) node.getCondition().acceptVisitor(this));
81     node.setBody(node.getBody().acceptVisitor(this));
82     return node;
83   }
84
85   /**
86    * Visits a ForStatement
87    * @param node the node to visit
88    */

89   public Node visit(ForStatement node) {
90     LinkedList<Node> init = null; // Add parameterization <Node>.
91
if (node.getInitialization() != null) {
92       init = new LinkedList<Node>(); // Add parameterization <Node>.
93
Iterator<Node> it = node.getInitialization().iterator();
94       while (it.hasNext()) {
95         init.add(it.next().acceptVisitor(this));
96       }
97     }
98     node.setInitialization(init);
99     Expression cond = null;
100     if (node.getCondition() != null) {
101       cond = (Expression)node.getCondition().acceptVisitor(this);
102     }
103     node.setCondition(cond);
104     LinkedList<Node> updt = null; // Add parameterization <Node>.
105
if (node.getUpdate() != null) {
106       updt = new LinkedList<Node>(); // Add parameterization <Node>.
107
Iterator<Node> it = node.getUpdate().iterator();
108       while (it.hasNext()) {
109         updt.add(it.next().acceptVisitor(this));
110       }
111     }
112     node.setUpdate(updt);
113     node.setBody(node.getBody().acceptVisitor(this));
114     return node;
115   }
116
117   /**
118    * Visits a ForEachStatement
119    * @param node the node to visit
120    */

121   public Node visit(ForEachStatement node) {
122     FormalParameter param = node.getParameter();
123     Expression collection = node.getCollection();
124     Node stmt = node.getBody();
125     
126     node.setParameter((FormalParameter)param.acceptVisitor(this));
127     node.setCollection((Expression)collection.acceptVisitor(this));
128     node.setBody(stmt.acceptVisitor(this));
129     
130     return node;
131   }
132
133   /**
134    * Visits a DoStatement
135    * @param node the node to visit
136    */

137   public Node visit(DoStatement node) {
138     Expression cond = (Expression) node.getCondition().acceptVisitor(this);
139     node.setCondition(cond);
140     Node body = node.getBody().acceptVisitor(this);
141     node.setBody(body);
142     return node;
143   }
144
145   /**
146    * Visits a SwitchStatement
147    * @param node the node to visit
148    */

149   public Node visit(SwitchStatement node) {
150     Expression sel = (Expression) node.getSelector().acceptVisitor(this);
151     node.setSelector(sel);
152     LinkedList<SwitchBlock> cases = new LinkedList<SwitchBlock>(); // Add parameterization <Node>.
153
Iterator<SwitchBlock> it = node.getBindings().iterator();
154     while (it.hasNext()) {
155       cases.add((SwitchBlock)it.next().acceptVisitor(this));
156     }
157     node.setBindings(cases);
158     return node;
159   }
160
161   /**
162    * Visits a SwitchBlock
163    * @param node the node to visit
164    */

165   public Node visit(SwitchBlock node) {
166     Expression e = null;
167     if (node.getExpression() != null) {
168       e = (Expression) node.getExpression().acceptVisitor(this);
169     }
170     node.setExpression(e);
171     LinkedList<Node> statements = null; // Add parameterization <Node>.
172
if (node.getStatements() != null) {
173       statements = new LinkedList<Node>(); // Add parameterization <Node>.
174
Iterator<Node> it = node.getStatements().iterator();
175       while (it.hasNext()) {
176         statements.add(it.next().acceptVisitor(this));
177       }
178     }
179     node.setStatements(statements);
180     return node;
181   }
182
183   /**
184    * Visits a LabeledStatement
185    * @param node the node to visit
186    */

187   public Node visit(LabeledStatement node) {
188     node.setStatement(node.getStatement().acceptVisitor(this));
189     return node;
190   }
191
192   /**
193    * Visits a BreakStatement
194    * @param node the node to visit
195    */

196   public Node visit(BreakStatement node) { return node; }
197
198   /**
199    * Visits a TryStatement
200    * @param node the node to visit
201    */

202   public Node visit(TryStatement node) {
203     Node tryBlock = node.getTryBlock().acceptVisitor(this);
204     LinkedList<CatchStatement> catchStatements = new LinkedList<CatchStatement>();
205     Iterator<CatchStatement> it = node.getCatchStatements().iterator();
206     while (it.hasNext()) {
207       catchStatements.add((CatchStatement)it.next().acceptVisitor(this));
208     }
209     Node finallyBlock = null;
210     if (node.getFinallyBlock() != null) {
211       finallyBlock = node.getFinallyBlock().acceptVisitor(this);
212     }
213     node = new TryStatement(tryBlock, catchStatements, finallyBlock, null, 0, 0, 0, 0);
214     return node;
215   }
216
217   /**
218    * Visits a CatchStatement
219    * @param node the node to visit
220    */

221   public Node visit(CatchStatement node) {
222     Node exp = node.getException().acceptVisitor(this);
223     Node block = node.getBlock().acceptVisitor(this);
224     node = new CatchStatement((FormalParameter)exp, block, null, 0, 0, 0, 0);
225     return node;
226   }
227
228   /**
229    * Visits a ThrowStatement
230    * @param node the node to visit
231    */

232   public Node visit(ThrowStatement node) {
233     node.setExpression((Expression)node.getExpression().acceptVisitor(this));
234     return node;
235   }
236
237   /**
238    * Visits a ReturnStatement
239    * @param node the node to visit
240    */

241   public Node visit(ReturnStatement node) {
242     node.setExpression((Expression)node.getExpression().acceptVisitor(this));
243     return node;
244   }
245
246   /**
247    * Visits a SynchronizedStatement
248    * @param node the node to visit
249    */

250   public Node visit(SynchronizedStatement node) {
251     node.setLock((Expression)node.getLock().acceptVisitor(this));
252     node.setBody(node.getBody().acceptVisitor(this));
253     return node;
254   }
255
256   /**
257    * Visits a ContinueStatement
258    * @param node the node to visit
259    */

260   public Node visit(ContinueStatement node) {
261     return node;
262   }
263
264   /**
265    * Visits a IfThenStatement
266    * @param node the node to visit
267    */

268   public Node visit(IfThenStatement node) {
269     node.setCondition((Expression)node.getCondition().acceptVisitor(this));
270     node.setThenStatement(node.getThenStatement().acceptVisitor(this));
271     return node;
272   }
273
274   /**
275    * Visits a IfThenElseStatement
276    * @param node the node to visit
277    */

278   public Node visit(IfThenElseStatement node) {
279     node.setCondition((Expression)node.getCondition().acceptVisitor(this));
280     node.setThenStatement(node.getThenStatement().acceptVisitor(this));
281     node.setElseStatement(node.getElseStatement().acceptVisitor(this));
282     return node;
283   }
284   
285   /**
286    * Visits an AssertStatement
287    * @param node the node to visit
288    */

289   public Node visit(AssertStatement node) {
290     node.setCondition((Expression)node.getCondition().acceptVisitor(this));
291     if (node.getFailString() != null)
292       node.setFailString((Expression)node.getFailString().acceptVisitor(this));
293     return node;
294   }
295
296   /**
297    * Visits a Literal
298    * @param node the node to visit
299    */

300   public Node visit(Literal node) { return node; }
301
302   /**
303    * Visits a ThisExpression
304    * @param node the node to visit
305    */

306   public Node visit(ThisExpression node) { return node; }
307
308   /**
309    * Visits a QualifiedName
310    * @param node the node to visit
311    */

312   public Node visit(QualifiedName node) {
313     return node;
314   }
315
316   /**
317    * Visits a ObjectFieldAccess
318    * @param node the node to visit
319    */

320   public Node visit(ObjectFieldAccess node) {
321     node.setExpression((Expression)node.getExpression().acceptVisitor(this));
322     return node;
323   }
324
325   /**
326    * Visits a StaticFieldAccess
327    * @param node the node to visit
328    */

329   public Node visit(StaticFieldAccess node) {
330     node.setFieldType((ReferenceType)node.getFieldType().acceptVisitor(this));
331     return node;
332   }
333
334   /**
335    * Visits a ArrayAccess
336    * @param node the node to visit
337    */

338   public Node visit(ArrayAccess node) {
339     node.setExpression((Expression)node.getExpression().acceptVisitor(this));
340     node.setCellNumber((Expression)node.getCellNumber().acceptVisitor(this));
341     return node;
342   }
343
344   /**
345    * Visits a SuperFieldAccess
346    * @param node the node to visit
347    */

348   public Node visit(SuperFieldAccess node) {
349     return node;
350   }
351
352   /**
353    * Visits a ObjectMethodCall
354    * @param node the node to visit
355    */

356   public Node visit(ObjectMethodCall node) {
357     if (node.getExpression() != null) {
358       node.setExpression((Expression)node.getExpression().acceptVisitor(this));
359     }
360     LinkedList<Expression> arguments = null; // Add parameterization <Node>.
361
if (node.getArguments() != null) {
362       arguments = new LinkedList<Expression>(); // Add parameterization <Node>.
363
Iterator<Expression> it = node.getArguments().iterator();
364       while (it.hasNext()) {
365         arguments.add((Expression) it.next().acceptVisitor(this));
366       }
367     }
368     node.setArguments(arguments);
369     return node;
370   }
371
372   /**
373    * Visits a FunctionCall
374    * @param node the node to visit
375    */

376   public Node visit(FunctionCall node) {
377     LinkedList<Expression> arguments = null; // Add parameterization <Node>.
378
if (node.getArguments() != null) {
379       arguments = new LinkedList<Expression>(); // Add parameterization <Node>.
380
Iterator<Expression> it = node.getArguments().iterator();
381       while (it.hasNext()) {
382         arguments.add((Expression) it.next().acceptVisitor(this));
383       }
384     }
385     node.setArguments(arguments);
386     return node;
387   }
388
389   /**
390    * Visits a StaticMethodCall
391    * @param node the node to visit
392    */

393   public Node visit(StaticMethodCall node) {
394     node.setMethodType((ReferenceType)node.getMethodType().acceptVisitor(this));
395     LinkedList<Expression> arguments = null; // Add parameterization <Node>.
396
if (node.getArguments() != null) {
397       arguments = new LinkedList<Expression>(); // Add parameterization <Node>.
398
Iterator<Expression> it = node.getArguments().iterator();
399       while (it.hasNext()) {
400         arguments.add((Expression)it.next().acceptVisitor(this));
401       }
402     }
403     node.setArguments(arguments);
404     return node;
405   }
406
407     /**
408      * Visits a ConstructorInvocation
409      * @param node the node to visit
410      */

411     public Node visit(ConstructorInvocation node) {
412       if (node.getExpression() != null) {
413         node.setExpression((Expression)node.getExpression().acceptVisitor(this));
414       }
415       LinkedList<Expression> arguments = null; // Add parameterization <Node>.
416
if (node.getArguments() != null) {
417         arguments = new LinkedList<Expression>(); // Add parameterization <Node>.
418
Iterator<Expression> it = node.getArguments().iterator();
419         while (it.hasNext()) {
420           arguments.add((Expression)it.next().acceptVisitor(this));
421         }
422       }
423       node.setArguments(arguments);
424       return node;
425     }
426
427     /**
428      * Visits a SuperMethodCall
429      * @param node the node to visit
430      */

431     public Node visit(SuperMethodCall node) {
432       LinkedList<Expression> arguments = null; // Add parameterization <Node>.
433
if (node.getArguments() != null) {
434         arguments = new LinkedList<Expression>(); // Add parameterization <Node>.
435
Iterator<Expression> it = node.getArguments().iterator();
436         while (it.hasNext()) {
437           arguments.add((Expression)it.next().acceptVisitor(this));
438         }
439       }
440       node.setArguments(arguments);
441       return node;
442     }
443
444     /**
445      * Visits a PrimitiveType
446      * @param node the node to visit
447      */

448     public Node visit(PrimitiveType node) { return node; }
449
450     /**
451      * Visits a ReferenceType
452      * @param node the node to visit
453      */

454     public Node visit(ReferenceType node) { return node; }
455
456     /**
457      * Visits a ArrayType
458      * @param node the node to visit
459      */

460     public Node visit(ArrayType node) {
461       if (node.getElementType() != null) {
462         node.setElementType((Type)node.getElementType().acceptVisitor(this));
463       }
464       return node;
465     }
466
467     /**
468      * Visits a TypeExpression
469      * @param node the node to visit
470      */

471     public Node visit(TypeExpression node) {
472       // For some reason, the setType expression in node only takes in
473
// ReferenceTypes so we have to create a new TypeExpression in
474
// case the visitor returns a PrimitiveType (e.g. int.class used
475
// to cause a ClassCastException).
476
node = new TypeExpression((Type)node.getType().acceptVisitor(this));
477       return node;
478     }
479
480     /**
481      * Visits a PostIncrement
482      * @param node the node to visit
483      */

484     public Node visit(PostIncrement node) { return _visitUnary(node); }
485
486     /**
487      * Visits a PostDecrement
488      * @param node the node to visit
489      */

490     public Node visit(PostDecrement node) { return _visitUnary(node); }
491
492     /**
493      * Visits a PreIncrement
494      * @param node the node to visit
495      */

496     public Node visit(PreIncrement node) { return _visitUnary(node); }
497
498     /**
499      * Visits a PreDecrement
500      * @param node the node to visit
501      */

502     public Node visit(PreDecrement node) { return _visitUnary(node); }
503
504     /**
505      * Visits a ArrayInitializer
506      * @param node the node to visit
507      */

508     public Node visit(ArrayInitializer node) {
509       LinkedList<Expression> cells = new LinkedList<Expression>(); // Add parameterization <Node>.
510
Iterator<Expression> it = node.getCells().iterator();
511       while (it.hasNext()) {
512         cells.add((Expression)it.next().acceptVisitor(this));
513       }
514       node.setCells(cells);
515       node.setElementType((Type)node.getElementType().acceptVisitor(this));
516       return node;
517     }
518
519     /**
520      * Visits an ArrayAllocation, check me on this one.
521      * @param node the node to visit
522      */

523     public Node visit(ArrayAllocation node) {
524       int dim = node.getDimension();
525       Type creationType = (Type)node.getCreationType().acceptVisitor(this);
526       LinkedList<Expression> sizes = new LinkedList<Expression>(); // Add parameterization <Expression>.
527
Iterator<Expression> it = node.getSizes().iterator();
528       while (it.hasNext()) {
529         sizes.add((Expression)it.next().acceptVisitor(this));
530       }
531       ArrayInitializer ai = null;
532       if (node.getInitialization() != null) {
533         ai = (ArrayInitializer)node.getInitialization().acceptVisitor(this);
534       }
535       node = new ArrayAllocation(creationType,
536                                  new ArrayAllocation.TypeDescriptor(sizes, dim, ai, 0, 0));
537       return node;
538     }
539
540     /**
541      * Visits an SimpleAllocation
542      * @param node the node to visit
543      */

544     public Node visit(SimpleAllocation node) {
545       node.setCreationType((Type)node.getCreationType().acceptVisitor(this));
546       LinkedList<Expression> arguments = null; // Add parameterization <Expresion>.
547
if (node.getArguments() != null) {
548         arguments = new LinkedList<Expression>(); // Add parameterization <Expression>.
549
Iterator<Expression> it = node.getArguments().iterator();
550         while (it.hasNext()) {
551           arguments.add((Expression)it.next().acceptVisitor(this));
552         }
553       }
554       node.setArguments(arguments);
555       return node;
556     }
557
558     /**
559      * Visits an ClassAllocation
560      * @param node the node to visit
561      */

562     public Node visit(ClassAllocation node) {
563       node.setCreationType((Type)node.getCreationType().acceptVisitor(this));
564       LinkedList<Expression> arguments = null; // Add parameterization <Expression>.
565
if (node.getArguments() != null) {
566         arguments = new LinkedList<Expression>(); // Add parameterization <Expression>.
567
Iterator<Expression> it = node.getArguments().iterator();
568         while (it.hasNext()) {
569           arguments.add((Expression)it.next().acceptVisitor(this));
570         }
571       }
572       node.setArguments(arguments);
573       LinkedList<Node> members = new LinkedList<Node>(); // Add parameterization <Node>.
574
Iterator<Node> it = node.getMembers().iterator();
575       while (it.hasNext()) {
576         members.add(it.next().acceptVisitor(this));
577       }
578       node.setMembers(members);
579       return node;
580     }
581
582     /**
583      * Visits an InnerAllocation
584      * @param node the node to visit
585      */

586     public Node visit(InnerAllocation node) {
587       node.setExpression((Expression)node.getExpression().acceptVisitor(this));
588       node.setCreationType((Type)node.getCreationType().acceptVisitor(this));
589       LinkedList<Expression> arguments = null; // Add parameterization <Expression>.
590
if (node.getArguments() != null) {
591         arguments = new LinkedList<Expression>(); // Add parameterization <Expression>.
592
Iterator<Expression> it = node.getArguments().iterator();
593         while (it.hasNext()) {
594           arguments.add((Expression)it.next().acceptVisitor(this));
595         }
596       }
597       node.setArguments(arguments);
598       return node;
599     }
600
601     /**
602      * Visits an InnerClassAllocation
603      * @param node the node to visit
604      */

605     public Node visit(InnerClassAllocation node) {
606       node.setExpression((Expression)node.getExpression().acceptVisitor(this));
607       node.setCreationType((Type)node.getCreationType().acceptVisitor(this));
608       LinkedList<Expression> arguments = null; // Add parameterization <Expression>.
609
if (node.getArguments() != null) {
610         arguments = new LinkedList<Expression>(); // Add parameterization <Expression>.
611
Iterator<Expression> it = node.getArguments().iterator();
612         while (it.hasNext()) {
613           arguments.add((Expression)it.next().acceptVisitor(this));
614         }
615       }
616       node.setArguments(arguments);
617       LinkedList<Node> members = new LinkedList<Node>(); // Add parameterization <Node>.
618
Iterator<Node> it = node.getMembers().iterator();
619       while (it.hasNext()) {
620         members.add(it.next().acceptVisitor(this));
621       }
622       node.setMembers(members);
623       return node;
624     }
625
626     /**
627      * Visits a CastExpression
628      * @param node the node to visit
629      */

630     public Node visit(CastExpression node) {
631       node.setTargetType((Type)node.getTargetType().acceptVisitor(this));
632       node.setExpression((Expression)node.getExpression().acceptVisitor(this));
633       return node;
634     }
635
636     /**
637      * Visits a NotExpression
638      * @param node the node to visit
639      */

640     public Node visit(NotExpression node) {
641       return _visitUnary(node);
642     }
643
644     /**
645      * Visits a ComplementExpression
646      * @param node the node to visit
647      */

648     public Node visit(ComplementExpression node) {
649       return _visitUnary(node);
650     }
651
652     /**
653      * Visits a PlusExpression
654      * @param node the node to visit
655      */

656     public Node visit(PlusExpression node) {
657       return _visitUnary(node);
658     }
659
660     /**
661      * Visits a MinusExpression
662      * @param node the node to visit
663      */

664     public Node visit(MinusExpression node) {
665       return _visitUnary(node);
666     }
667
668     /**
669      * Visits a MultiplyExpression
670      * @param node the node to visit
671      */

672     public Node visit(MultiplyExpression node) {
673       return _visitBinary(node);
674     }
675
676     /**
677      * Visits a DivideExpression
678      * @param node the node to visit
679      */

680     public Node visit(DivideExpression node) {
681       return _visitBinary(node);
682     }
683
684     /**
685      * Visits a RemainderExpression
686      * @param node the node to visit
687      */

688     public Node visit(RemainderExpression node) {
689       return _visitBinary(node);
690     }
691
692     /**
693      * Visits a AddExpression
694      * @param node the node to visit
695      */

696     public Node visit(AddExpression node) {
697       return _visitBinary(node);
698     }
699
700     /**
701      * Visits a SubtractExpression
702      * @param node the node to visit
703      */

704     public Node visit(SubtractExpression node) {
705       return _visitBinary(node);
706     }
707
708     /**
709      * Visits a ShiftLeftExpression
710      * @param node the node to visit
711      */

712     public Node visit(ShiftLeftExpression node) {
713       return _visitBinary(node);
714     }
715
716     /**
717      * Visits a ShiftRightExpression
718      * @param node the node to visit
719      */

720     public Node visit(ShiftRightExpression node) {
721       return _visitBinary(node);
722     }
723
724     /**
725      * Visits a UnsignedShiftRightExpression
726      * @param node the node to visit
727      */

728     public Node visit(UnsignedShiftRightExpression node) {
729       return _visitBinary(node);
730     }
731
732     /**
733      * Visits a LessExpression
734      * @param node the node to visit
735      */

736     public Node visit(LessExpression node) {
737       return _visitBinary(node);
738     }
739
740     /**
741      * Visits a GreaterExpression
742      * @param node the node to visit
743      */

744     public Node visit(GreaterExpression node) {
745       return _visitBinary(node);
746     }
747
748     /**
749      * Visits a LessOrEqualExpression
750      * @param node the node to visit
751      */

752     public Node visit(LessOrEqualExpression node) {
753       return _visitBinary(node);
754     }
755
756     /**
757      * Visits a GreaterOrEqualExpression
758      * @param node the node to visit
759      */

760     public Node visit(GreaterOrEqualExpression node) {
761       return _visitBinary(node);
762     }
763
764     /**
765      * Visits a InstanceOfExpression
766      * @param node the node to visit
767      */

768     public Node visit(InstanceOfExpression node) {
769       node.setExpression((Expression)node.getExpression().acceptVisitor(this));
770       node.setReferenceType((Type)node.getReferenceType().acceptVisitor(this));
771       return node;
772     }
773
774     /**
775      * Visits a EqualExpression
776      * @param node the node to visit
777      */

778     public Node visit(EqualExpression node) {
779       return _visitBinary(node);
780     }
781
782     /**
783      * Visits a NotEqualExpression
784      * @param node the node to visit
785      */

786     public Node visit(NotEqualExpression node) {
787       return _visitBinary(node);
788     }
789
790     /**
791      * Visits a BitAndExpression
792      * @param node the node to visit
793      */

794     public Node visit(BitAndExpression node) {
795       return _visitBinary(node);
796     }
797
798     /**
799      * Visits a ExclusiveOrExpression
800      * @param node the node to visit
801      */

802     public Node visit(ExclusiveOrExpression node) {
803       return _visitBinary(node);
804     }
805
806     /**
807      * Visits a BitOrExpression
808      * @param node the node to visit
809      */

810     public Node visit(BitOrExpression node) {
811       return _visitBinary(node);
812     }
813
814     /**
815      * Visits an AndExpression
816      * @param node the node to visit
817      */

818     public Node visit(AndExpression node) {
819       return _visitBinary(node);
820     }
821
822     /**
823      * Visits an OrExpression
824      * @param node the node to visit
825      */

826     public Node visit(OrExpression node) {
827       return _visitBinary(node);
828     }
829
830     /**
831      * Visits a ConditionalExpression
832      * @param node the node to visit
833      */

834     public Node visit(ConditionalExpression node) {
835       node.setConditionExpression((Expression)node.getConditionExpression().acceptVisitor(this));
836       node.setIfTrueExpression((Expression)node.getIfTrueExpression().acceptVisitor(this));
837       node.setIfFalseExpression((Expression)node.getIfFalseExpression().acceptVisitor(this));
838       return node;
839     }
840
841     /**
842      * Visits an SimpleAssignExpression
843      * @param node the node to visit
844      */

845     public Node visit(SimpleAssignExpression node) {
846       return _visitBinary(node);
847     }
848
849     /**
850      * Visits an MultiplyAssignExpression
851      * @param node the node to visit
852      */

853     public Node visit(MultiplyAssignExpression node) {
854       return _visitBinary(node);
855     }
856
857     /**
858      * Visits an DivideAssignExpression
859      * @param node the node to visit
860      */

861     public Node visit(DivideAssignExpression node) {
862       return _visitBinary(node);
863     }
864
865     /**
866      * Visits an RemainderAssignExpression
867      * @param node the node to visit
868      */

869     public Node visit(RemainderAssignExpression node) {
870       return _visitBinary(node);
871     }
872
873     /**
874      * Visits an AddAssignExpression
875      * @param node the node to visit
876      */

877     public Node visit(AddAssignExpression node) {
878       return _visitBinary(node);
879     }
880
881     /**
882      * Visits an SubtractAssignExpression
883      * @param node the node to visit
884      */

885     public Node visit(SubtractAssignExpression node) {
886       return _visitBinary(node);
887     }
888
889     /**
890      * Visits an ShiftLeftAssignExpression
891      * @param node the node to visit
892      */

893     public Node visit(ShiftLeftAssignExpression node) {
894       return _visitBinary(node);
895     }
896
897     /**
898      * Visits an ShiftRightAssignExpression
899      * @param node the node to visit
900      */

901     public Node visit(ShiftRightAssignExpression node) {
902       return _visitBinary(node);
903     }
904
905     /**
906      * Visits an UnsignedShiftRightAssignExpression
907      * @param node the node to visit
908      */

909     public Node visit(UnsignedShiftRightAssignExpression node) {
910       return _visitBinary(node);
911     }
912
913     /**
914      * Visits a BitAndAssignExpression
915      * @param node the node to visit
916      */

917     public Node visit(BitAndAssignExpression node) {
918       return _visitBinary(node);
919     }
920
921     /**
922      * Visits a ExclusiveOrAssignExpression
923      * @param node the node to visit
924      */

925     public Node visit(ExclusiveOrAssignExpression node) {
926       return _visitBinary(node);
927     }
928
929     /**
930      * Visits a BitOrAssignExpression
931      * @param node the node to visit
932      */

933     public Node visit(BitOrAssignExpression node) {
934       return _visitBinary(node);
935     }
936
937     /**
938      * Visits a BlockStatement
939      * @param node the node to visit
940      */

941     public Node visit(BlockStatement node) {
942       LinkedList<Node> statements = new LinkedList<Node>(); // Add parameterization <Node>.
943
Iterator<Node> it = node.getStatements().iterator();
944       while (it.hasNext()) {
945         statements.add(it.next().acceptVisitor(this));
946       }
947       node.setStatements(statements);
948       return node;
949     }
950
951     /**
952      * Visits a ClassDeclaration
953      * @param node the node to visit
954      */

955     public Node visit(ClassDeclaration node) {
956       LinkedList<Node> members = new LinkedList<Node>(); // Add parameterization <Node>.
957
Iterator<Node> it = node.getMembers().iterator();
958       while (it.hasNext()) {
959         members.add(it.next().acceptVisitor(this));
960       }
961       node.setMembers(members);
962       return node;
963     }
964
965     /**
966      * Visits an InterfaceDeclaration
967      * @param node the node to visit
968      */

969     public Node visit(InterfaceDeclaration node) {
970       LinkedList<Node> members = new LinkedList<Node>(); // Add parameterization <Node>.
971
Iterator<Node> it = node.getMembers().iterator();
972       while (it.hasNext()) {
973         members.add(it.next().acceptVisitor(this));
974       }
975       node.setMembers(members);
976       return node;
977     }
978
979     /**
980      * Visits a ConstructorDeclaration
981      * @param node the node to visit
982      */

983     public Node visit(ConstructorDeclaration node) {
984       LinkedList<FormalParameter> parameters = new LinkedList<FormalParameter>(); // Add parameterization <Node>.
985
Iterator<FormalParameter> it1 = node.getParameters().iterator();
986       while (it1.hasNext()) {
987         parameters.add((FormalParameter)it1.next().acceptVisitor(this));
988       }
989       node.setParameters(parameters);
990       if (node.getConstructorInvocation() != null) {
991         node.setConstructorInvocation((ConstructorInvocation)node.getConstructorInvocation().acceptVisitor(this));
992       }
993       LinkedList<Node> statements = new LinkedList<Node>(); // Add parameterization <Node>.
994
Iterator<Node> it2 = node.getStatements().iterator();
995       while (it2.hasNext()) {
996         statements.add(it2.next().acceptVisitor(this));
997       }
998       node.setStatements(statements);
999       return node;
1000    }
1001
1002    /**
1003     * Visits a MethodDeclaration
1004     * @param node the node to visit
1005     */

1006    public Node visit(MethodDeclaration node) {
1007      node.setReturnType((Type)node.getReturnType().acceptVisitor(this));
1008      LinkedList<FormalParameter> parameters = new LinkedList<FormalParameter>(); // Add parameterization <Node>.
1009
Iterator<FormalParameter> it = node.getParameters().iterator();
1010      while (it.hasNext()) {
1011        parameters.add((FormalParameter)it.next().acceptVisitor(this));
1012      }
1013      node.setParameters(parameters);
1014      if (node.getBody() != null) {
1015        node.setBody((BlockStatement)node.getBody().acceptVisitor(this));
1016      }
1017      return node;
1018    }
1019
1020    /**
1021     * Visits a FormalParameter
1022     * @param node the node to visit
1023     */

1024    public Node visit(FormalParameter node) {
1025      node.setType((Type)node.getType().acceptVisitor(this));
1026      return node;
1027    }
1028
1029    /**
1030     * Visits a FieldDeclaration
1031     * @param node the node to visit
1032     */

1033    public Node visit(FieldDeclaration node) {
1034      node.setType((Type)node.getType().acceptVisitor(this));
1035      if (node.getInitializer() != null) {
1036        node.setInitializer((Expression)node.getInitializer().acceptVisitor(this));
1037      }
1038      return node;
1039    }
1040
1041    /**
1042     * Visits a VariableDeclaration
1043     * @param node the node to visit
1044     */

1045    public Node visit(VariableDeclaration node) {
1046      node.setType((Type)node.getType().acceptVisitor(this));
1047      if (node.getInitializer() != null) {
1048        node.setInitializer((Expression)node.getInitializer().acceptVisitor(this));
1049      }
1050      return node;
1051    }
1052
1053    /**
1054     * Visits a ClassInitializer
1055     * @param node the node to visit
1056     */

1057    public Node visit(ClassInitializer node) {
1058      node.setBlock((BlockStatement)node.getBlock().acceptVisitor(this));
1059      return node;
1060    }
1061
1062    /**
1063     * Visits a InstanceInitializer
1064     * @param node the node to visit
1065     */

1066    public Node visit(InstanceInitializer node) {
1067      node.setBlock((BlockStatement)node.getBlock().acceptVisitor(this));
1068      return node;
1069    }
1070
1071    private Node _visitUnary(UnaryExpression node) {
1072      node.setExpression((Expression)node.getExpression().acceptVisitor(this));
1073      return node;
1074    }
1075
1076    private Node _visitBinary(BinaryExpression node) {
1077      node.setLeftExpression((Expression)node.getLeftExpression().acceptVisitor(this));
1078      node.setRightExpression((Expression)node.getRightExpression().acceptVisitor(this));
1079      return node;
1080    }
1081}
1082
Popular Tags