KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > corext > dom > HierarchicalASTVisitor


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.corext.dom;
12
13 import org.eclipse.jdt.core.dom.*;
14
15 /**
16  * <p>This class provides a convenient behaviour-only
17  * extension mechanism for the ASTNode hierarchy.
18  * If you feel like you would like to add a method to
19  * the ASTNode hierarchy (or a subtree of the hierarchy),
20  * and you want to have different implementations
21  * of it at different points in the hierarchy,
22  * simply create a HierarchicalASTVisitor representing
23  * the new method and all its implementations,
24  * locating each implementation within the right
25  * visit(XX) method. If you wanted to add a method implementation to abstract
26  * class Foo, an ASTNode descendant, put your implementation in visit(Foo).
27  * This class will provide appropriate dispatch, just as if the method
28  * implementations had been added to the ASTNode hierarchy.
29  * </p>
30  *
31  * <p><b>Details:<b></p>
32  *
33  * <p>This class has a visit(XX node) method for every for every
34  * class (concrete or abstract) XX in the ASTNode hierarchy. In this class'
35  * default implementations of these methods, the method corresponding to a given
36  * ASTNode descendant class will call (and return the return value of) the
37  * visit(YY) method for it's superclass YY, with the exception of the
38  * visit(ASTNode) method which simply returns true, since ASTNode doesn't have a
39  * superclass that is within the ASTNode hierarchy.
40  * </p>
41  *
42  * <p>Because of this organization, when visit(XX) methods are overridden in a
43  * subclass, and the visitor is applied to a node, only the most specialized
44  * overridden method implementation for the node's type will be called, unless
45  * this most specialized method calls other visit methods (this is discouraged)
46  * or, (preferably) calls super.visit(XX node), (the reference type of the
47  * parameter must be XX) which will invoke this class' implementation of the
48  * method, which will, in turn, invoke the visit(YY) method corresponding to the
49  * superclass, YY.
50  * </p>
51  *
52  * <p>Thus, the dispatching behaviour achieved when
53  * HierarchicalASTVisitors' visit(XX) methods, corresponding to a particular
54  * concrete or abstract ASTNode descendant class, are overridden is exactly
55  * analogous to the dispatching behaviour obtained when method implementations
56  * are added to the same ASTNode descendant classes.
57  * </p>
58  */

59 /*
60  * IMPORTANT NOTE:
61  *
62  * The structure and behaviour of this class is
63  * verified reflectively by
64  * org.eclipse.jdt.ui.tests.core.HierarchicalASTVisitorTest
65  *
66  */

67 public abstract class HierarchicalASTVisitor extends ASTVisitor {
68 //TODO: check callers for handling of comments
69

70 //---- Begin ASTNode Hierarchy -------------------------------------
71
public boolean visit(ASTNode node) {
72     return true;
73 }
74 public void endVisit(ASTNode node) {
75     // do nothing
76
}
77
78 public boolean visit(AnonymousClassDeclaration node) {
79     return visit((ASTNode) node);
80 }
81 public void endVisit(AnonymousClassDeclaration node) {
82     endVisit((ASTNode) node);
83 }
84
85 //---- Begin BodyDeclaration Hierarchy ---------------------------
86
public boolean visit(BodyDeclaration node) {
87     return visit((ASTNode) node);
88 }
89 public void endVisit(BodyDeclaration node) {
90     endVisit((ASTNode) node);
91 }
92
93     //---- Begin AbstractTypeDeclaration Hierarchy ---------------------------
94
public boolean visit(AbstractTypeDeclaration node) {
95         return visit((BodyDeclaration) node);
96     }
97     public void endVisit(AbstractTypeDeclaration node) {
98         endVisit((BodyDeclaration) node);
99     }
100     
101         public boolean visit(AnnotationTypeDeclaration node) {
102             return visit((AbstractTypeDeclaration) node);
103         }
104         public void endVisit(AnnotationTypeDeclaration node) {
105             endVisit((AbstractTypeDeclaration) node);
106         }
107         
108         public boolean visit(EnumDeclaration node) {
109             return visit((AbstractTypeDeclaration) node);
110         }
111         public void endVisit(EnumDeclaration node) {
112             endVisit((AbstractTypeDeclaration) node);
113         }
114         
115         public boolean visit(TypeDeclaration node) {
116             return visit((AbstractTypeDeclaration) node);
117         }
118         public void endVisit(TypeDeclaration node) {
119             endVisit((AbstractTypeDeclaration) node);
120         }
121     //---- End AbstractTypeDeclaration Hierarchy ---------------------------
122

123     public boolean visit(AnnotationTypeMemberDeclaration node) {
124         return visit((BodyDeclaration) node);
125     }
126     public void endVisit(AnnotationTypeMemberDeclaration node) {
127         endVisit((BodyDeclaration) node);
128     }
129     
130     public boolean visit(EnumConstantDeclaration node) {
131         return visit((BodyDeclaration) node);
132     }
133     public void endVisit(EnumConstantDeclaration node) {
134         endVisit((BodyDeclaration) node);
135     }
136     
137     public boolean visit(FieldDeclaration node) {
138         return visit((BodyDeclaration) node);
139     }
140     public void endVisit(FieldDeclaration node) {
141         endVisit((BodyDeclaration) node);
142     }
143     
144     public boolean visit(Initializer node) {
145         return visit((BodyDeclaration) node);
146     }
147     public void endVisit(Initializer node) {
148         endVisit((BodyDeclaration) node);
149     }
150     
151     public boolean visit(MethodDeclaration node) {
152         return visit((BodyDeclaration) node);
153     }
154     public void endVisit(MethodDeclaration node) {
155         endVisit((BodyDeclaration) node);
156     }
157     
158 //---- End BodyDeclaration Hierarchy -----------------------------
159

160 public boolean visit(CatchClause node) {
161     return visit((ASTNode) node);
162 }
163 public void endVisit(CatchClause node) {
164     endVisit((ASTNode) node);
165 }
166
167 //---- Begin Comment Hierarchy ----------------------------------
168
public boolean visit(Comment node) {
169     return visit((ASTNode) node);
170 }
171 public void endVisit(Comment node) {
172     endVisit((ASTNode) node);
173 }
174
175     public boolean visit(BlockComment node) {
176         return visit((Comment) node);
177     }
178     public void endVisit(BlockComment node) {
179         endVisit((Comment) node);
180     }
181     
182     public boolean visit(Javadoc node) {
183         return visit((Comment) node);
184     }
185     public void endVisit(Javadoc node) {
186         endVisit((Comment) node);
187     }
188     
189     public boolean visit(LineComment node) {
190         return visit((Comment) node);
191     }
192     public void endVisit(LineComment node) {
193         endVisit((Comment) node);
194     }
195     
196 //---- End Comment Hierarchy -----------------------------
197

198 public boolean visit(CompilationUnit node) {
199     return visit((ASTNode) node);
200 }
201 public void endVisit(CompilationUnit node) {
202     endVisit((ASTNode) node);
203 }
204
205 //---- Begin Expression Hierarchy ----------------------------------
206
public boolean visit(Expression node) {
207     return visit((ASTNode) node);
208 }
209 public void endVisit(Expression node) {
210     endVisit((ASTNode) node);
211 }
212
213     //---- Begin Annotation Hierarchy ----------------------------------
214
public boolean visit(Annotation node) {
215         return visit((Expression) node);
216     }
217     public void endVisit(Annotation node) {
218         endVisit((Expression) node);
219     }
220     
221         public boolean visit(MarkerAnnotation node) {
222             return visit((Annotation) node);
223         }
224         public void endVisit(MarkerAnnotation node) {
225             endVisit((Annotation) node);
226         }
227         
228         public boolean visit(NormalAnnotation node) {
229             return visit((Annotation) node);
230         }
231         public void endVisit(NormalAnnotation node) {
232             endVisit((Annotation) node);
233         }
234         
235         public boolean visit(SingleMemberAnnotation node) {
236             return visit((Annotation) node);
237         }
238         public void endVisit(SingleMemberAnnotation node) {
239             endVisit((Annotation) node);
240         }
241         
242     //---- End Annotation Hierarchy -----------------------------
243

244     public boolean visit(ArrayAccess node) {
245         return visit((Expression) node);
246     }
247     public void endVisit(ArrayAccess node) {
248         endVisit((Expression) node);
249     }
250     
251     public boolean visit(ArrayCreation node) {
252         return visit((Expression) node);
253     }
254     public void endVisit(ArrayCreation node) {
255         endVisit((Expression) node);
256     }
257     
258     public boolean visit(ArrayInitializer node) {
259         return visit((Expression) node);
260     }
261     public void endVisit(ArrayInitializer node) {
262         endVisit((Expression) node);
263     }
264     
265     public boolean visit(Assignment node) {
266         return visit((Expression) node);
267     }
268     public void endVisit(Assignment node) {
269         endVisit((Expression) node);
270     }
271     
272     public boolean visit(BooleanLiteral node) {
273         return visit((Expression) node);
274     }
275     public void endVisit(BooleanLiteral node) {
276         endVisit((Expression) node);
277     }
278     
279     public boolean visit(CastExpression node) {
280         return visit((Expression) node);
281     }
282     public void endVisit(CastExpression node) {
283         endVisit((Expression) node);
284     }
285     
286     public boolean visit(CharacterLiteral node) {
287         return visit((Expression) node);
288     }
289     public void endVisit(CharacterLiteral node) {
290         endVisit((Expression) node);
291     }
292     
293     public boolean visit(ClassInstanceCreation node) {
294         return visit((Expression) node);
295     }
296     public void endVisit(ClassInstanceCreation node) {
297         endVisit((Expression) node);
298     }
299     
300     public boolean visit(ConditionalExpression node) {
301         return visit((Expression) node);
302     }
303     public void endVisit(ConditionalExpression node) {
304         endVisit((Expression) node);
305     }
306     
307     public boolean visit(FieldAccess node) {
308         return visit((Expression) node);
309     }
310     public void endVisit(FieldAccess node) {
311         endVisit((Expression) node);
312     }
313     
314     public boolean visit(InfixExpression node) {
315         return visit((Expression) node);
316     }
317     public void endVisit(InfixExpression node) {
318         endVisit((Expression) node);
319     }
320     
321     public boolean visit(InstanceofExpression node) {
322         return visit((Expression) node);
323     }
324     public void endVisit(InstanceofExpression node) {
325         endVisit((Expression) node);
326     }
327     
328     public boolean visit(MethodInvocation node) {
329         return visit((Expression) node);
330     }
331     public void endVisit(MethodInvocation node) {
332         endVisit((Expression) node);
333     }
334
335     //---- Begin Name Hierarchy ----------------------------------
336
public boolean visit(Name node) {
337         return visit((Expression) node);
338     }
339     public void endVisit(Name node) {
340         endVisit((Expression) node);
341     }
342
343         public boolean visit(QualifiedName node) {
344             return visit((Name) node);
345         }
346         public void endVisit(QualifiedName node) {
347             endVisit((Name) node);
348         }
349         
350         public boolean visit(SimpleName node) {
351             return visit((Name) node);
352         }
353         public void endVisit(SimpleName node) {
354             endVisit((Name) node);
355         }
356         
357     //---- End Name Hierarchy ------------------------------------
358

359     public boolean visit(NullLiteral node) {
360         return visit((Expression) node);
361     }
362     public void endVisit(NullLiteral node) {
363         endVisit((Expression) node);
364     }
365     
366     public boolean visit(NumberLiteral node) {
367         return visit((Expression) node);
368     }
369     public void endVisit(NumberLiteral node) {
370         endVisit((Expression) node);
371     }
372     
373     public boolean visit(ParenthesizedExpression node) {
374         return visit((Expression) node);
375     }
376     public void endVisit(ParenthesizedExpression node) {
377         endVisit((Expression) node);
378     }
379     
380     public boolean visit(PostfixExpression node) {
381         return visit((Expression) node);
382     }
383     public void endVisit(PostfixExpression node) {
384         endVisit((Expression) node);
385     }
386     
387     public boolean visit(PrefixExpression node) {
388         return visit((Expression) node);
389     }
390     public void endVisit(PrefixExpression node) {
391         endVisit((Expression) node);
392     }
393     
394     public boolean visit(StringLiteral node) {
395         return visit((Expression) node);
396     }
397     public void endVisit(StringLiteral node) {
398         endVisit((Expression) node);
399     }
400     
401     public boolean visit(SuperFieldAccess node) {
402         return visit((Expression) node);
403     }
404     public void endVisit(SuperFieldAccess node) {
405         endVisit((Expression) node);
406     }
407     
408     public boolean visit(SuperMethodInvocation node) {
409         return visit((Expression) node);
410     }
411     public void endVisit(SuperMethodInvocation node) {
412         endVisit((Expression) node);
413     }
414     
415     public boolean visit(ThisExpression node) {
416         return visit((Expression) node);
417     }
418     public void endVisit(ThisExpression node) {
419         endVisit((Expression) node);
420     }
421     
422     public boolean visit(TypeLiteral node) {
423         return visit((Expression) node);
424     }
425     public void endVisit(TypeLiteral node) {
426         endVisit((Expression) node);
427     }
428     
429     public boolean visit(VariableDeclarationExpression node) {
430         return visit((Expression) node);
431     }
432     public void endVisit(VariableDeclarationExpression node) {
433         endVisit((Expression) node);
434     }
435
436     //---- End Expression Hierarchy ----------------------------------
437

438 public boolean visit(ImportDeclaration node) {
439     return visit((ASTNode) node);
440 }
441 public void endVisit(ImportDeclaration node) {
442     endVisit((ASTNode) node);
443 }
444
445 public boolean visit(MemberRef node) {
446     return visit((ASTNode) node);
447 }
448 public void endVisit(MemberRef node) {
449     endVisit((ASTNode) node);
450 }
451
452 public boolean visit(MemberValuePair node) {
453     return visit((ASTNode) node);
454 }
455 public void endVisit(MemberValuePair node) {
456     endVisit((ASTNode) node);
457 }
458
459 public boolean visit(MethodRef node) {
460     return visit((ASTNode) node);
461 }
462 public void endVisit(MethodRef node) {
463     endVisit((ASTNode) node);
464 }
465
466 public boolean visit(MethodRefParameter node) {
467     return visit((ASTNode) node);
468 }
469 public void endVisit(MethodRefParameter node) {
470     endVisit((ASTNode) node);
471 }
472
473 public boolean visit(Modifier node) {
474     return visit((ASTNode) node);
475 }
476 public void endVisit(Modifier node) {
477     endVisit((ASTNode) node);
478 }
479
480 public boolean visit(PackageDeclaration node) {
481     return visit((ASTNode) node);
482 }
483 public void endVisit(PackageDeclaration node) {
484     endVisit((ASTNode) node);
485 }
486
487 //---- Begin Statement Hierarchy ---------------------------------
488
public boolean visit(Statement node) {
489     return visit((ASTNode) node);
490 }
491 public void endVisit(Statement node) {
492     endVisit((ASTNode) node);
493 }
494
495
496     public boolean visit(AssertStatement node) {
497         return visit((Statement) node);
498     }
499     public void endVisit(AssertStatement node) {
500         endVisit((Statement) node);
501     }
502     
503     public boolean visit(Block node) {
504         return visit((Statement) node);
505     }
506     public void endVisit(Block node) {
507         endVisit((Statement) node);
508     }
509     
510     public boolean visit(BreakStatement node) {
511         return visit((Statement) node);
512     }
513     public void endVisit(BreakStatement node) {
514         endVisit((Statement) node);
515     }
516     
517     public boolean visit(ConstructorInvocation node) {
518         return visit((Statement) node);
519     }
520     public void endVisit(ConstructorInvocation node) {
521         endVisit((Statement) node);
522     }
523     
524     public boolean visit(ContinueStatement node) {
525         return visit((Statement) node);
526     }
527     public void endVisit(ContinueStatement node) {
528         endVisit((Statement) node);
529     }
530     
531     public boolean visit(DoStatement node) {
532         return visit((Statement) node);
533     }
534     public void endVisit(DoStatement node) {
535         endVisit((Statement) node);
536     }
537     
538     public boolean visit(EmptyStatement node) {
539         return visit((Statement) node);
540     }
541     public void endVisit(EmptyStatement node) {
542         endVisit((Statement) node);
543     }
544     
545     public boolean visit(EnhancedForStatement node) {
546         return visit((Statement) node);
547     }
548     public void endVisit(EnhancedForStatement node) {
549         endVisit((Statement) node);
550     }
551     
552     public boolean visit(ExpressionStatement node) {
553         return visit((Statement) node);
554     }
555     public void endVisit(ExpressionStatement node) {
556         endVisit((Statement) node);
557     }
558     
559     public boolean visit(ForStatement node) {
560         return visit((Statement) node);
561     }
562     public void endVisit(ForStatement node) {
563         endVisit((Statement) node);
564     }
565     
566     public boolean visit(IfStatement node) {
567         return visit((Statement) node);
568     }
569     public void endVisit(IfStatement node) {
570         endVisit((Statement) node);
571     }
572     
573     public boolean visit(LabeledStatement node) {
574         return visit((Statement) node);
575     }
576     public void endVisit(LabeledStatement node) {
577         endVisit((Statement) node);
578     }
579     
580     public boolean visit(ReturnStatement node) {
581         return visit((Statement) node);
582     }
583     public void endVisit(ReturnStatement node) {
584         endVisit((Statement) node);
585     }
586     
587     public boolean visit(SuperConstructorInvocation node) {
588         return visit((Statement) node);
589     }
590     public void endVisit(SuperConstructorInvocation node) {
591         endVisit((Statement) node);
592     }
593     
594     public boolean visit(SwitchCase node) {
595         return visit((Statement) node);
596     }
597     public void endVisit(SwitchCase node) {
598         endVisit((Statement) node);
599     }
600     
601     public boolean visit(SwitchStatement node) {
602         return visit((Statement) node);
603     }
604     public void endVisit(SwitchStatement node) {
605         endVisit((Statement) node);
606     }
607     
608     public boolean visit(SynchronizedStatement node) {
609         return visit((Statement) node);
610     }
611     public void endVisit(SynchronizedStatement node) {
612         endVisit((Statement) node);
613     }
614     
615     public boolean visit(ThrowStatement node) {
616         return visit((Statement) node);
617     }
618     public void endVisit(ThrowStatement node) {
619         endVisit((Statement) node);
620     }
621     
622     public boolean visit(TryStatement node) {
623         return visit((Statement) node);
624     }
625     public void endVisit(TryStatement node) {
626         endVisit((Statement) node);
627     }
628     
629     public boolean visit(TypeDeclarationStatement node) {
630         return visit((Statement) node);
631     }
632     public void endVisit(TypeDeclarationStatement node) {
633         endVisit((Statement) node);
634     }
635     
636     public boolean visit(VariableDeclarationStatement node) {
637         return visit((Statement) node);
638     }
639     public void endVisit(VariableDeclarationStatement node) {
640         endVisit((Statement) node);
641     }
642     
643     public boolean visit(WhileStatement node) {
644         return visit((Statement) node);
645     }
646     public void endVisit(WhileStatement node) {
647         endVisit((Statement) node);
648     }
649     
650 //---- End Statement Hierarchy ----------------------------------
651

652 public boolean visit(TagElement node) {
653     return visit((ASTNode) node);
654 }
655 public void endVisit(TagElement node) {
656     endVisit((ASTNode) node);
657 }
658
659 public boolean visit(TextElement node) {
660     return visit((ASTNode) node);
661 }
662 public void endVisit(TextElement node) {
663     endVisit((ASTNode) node);
664 }
665
666
667 //---- Begin Type Hierarchy --------------------------------------
668
public boolean visit(Type node) {
669     return visit((ASTNode) node);
670 }
671 public void endVisit(Type node) {
672     endVisit((ASTNode) node);
673 }
674
675     public boolean visit(ArrayType node) {
676         return visit((Type) node);
677     }
678     public void endVisit(ArrayType node) {
679         endVisit((Type) node);
680     }
681     
682     public boolean visit(ParameterizedType node) {
683         return visit((Type) node);
684     }
685     public void endVisit(ParameterizedType node) {
686         endVisit((Type) node);
687     }
688     
689     public boolean visit(PrimitiveType node) {
690         return visit((Type) node);
691     }
692     public void endVisit(PrimitiveType node) {
693         endVisit((Type) node);
694     }
695     
696     public boolean visit(QualifiedType node) {
697         return visit((Type) node);
698     }
699     public void endVisit(QualifiedType node) {
700         endVisit((Type) node);
701     }
702     
703     public boolean visit(SimpleType node) {
704         return visit((Type) node);
705     }
706     public void endVisit(SimpleType node) {
707         endVisit((Type) node);
708     }
709     
710     public boolean visit(WildcardType node) {
711         return visit((Type) node);
712     }
713     public void endVisit(WildcardType node) {
714         endVisit((Type) node);
715     }
716     
717 //---- End Type Hierarchy ----------------------------------------
718

719 public boolean visit(TypeParameter node) {
720     return visit((ASTNode) node);
721 }
722 public void endVisit(TypeParameter node) {
723     endVisit((ASTNode) node);
724 }
725
726
727 //---- Begin VariableDeclaration Hierarchy ---------------------------
728
public boolean visit(VariableDeclaration node) {
729     return visit((ASTNode) node);
730 }
731 public void endVisit(VariableDeclaration node) {
732     endVisit((ASTNode) node);
733 }
734
735     public boolean visit(SingleVariableDeclaration node) {
736         return visit((VariableDeclaration) node);
737     }
738     public void endVisit(SingleVariableDeclaration node) {
739         endVisit((VariableDeclaration) node);
740     }
741
742     public boolean visit(VariableDeclarationFragment node) {
743         return visit((VariableDeclaration) node);
744     }
745     public void endVisit(VariableDeclarationFragment node) {
746         endVisit((VariableDeclaration) node);
747     }
748
749 //---- End VariableDeclaration Hierarchy -----------------------------
750
//---- End ASTNode Hierarchy -----------------------------------------
751
}
752
Popular Tags