1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler;
13 import org.eclipse.jdt.core.compiler.*;
14 import org.eclipse.jdt.internal.compiler.ast.*;
15 import org.eclipse.jdt.internal.compiler.lookup.*;
18 * A visitor for iterating through the parse tree.
20 public abstract class ASTVisitor {
22 public void acceptProblem(IProblem problem) {
23 // do nothing by default
26 AllocationExpression allocationExpression,
28 // do nothing by default
30 public void endVisit(AND_AND_Expression and_and_Expression, BlockScope scope) {
31 // do nothing by default
34 AnnotationMethodDeclaration annotationTypeDeclaration,
35 ClassScope classScope) {
36 // do nothing by default
38 public void endVisit(Argument argument, BlockScope scope) {
39 // do nothing by default
42 ArrayAllocationExpression arrayAllocationExpression,
44 // do nothing by default
46 public void endVisit(ArrayInitializer arrayInitializer, BlockScope scope) {
47 // do nothing by default
50 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
52 // do nothing by default
55 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
57 // do nothing by default
59 public void endVisit(ArrayReference arrayReference, BlockScope scope) {
60 // do nothing by default
62 public void endVisit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
63 // do nothing by default
65 public void endVisit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
66 // do nothing by default
68 public void endVisit(AssertStatement assertStatement, BlockScope scope) {
69 // do nothing by default
71 public void endVisit(Assignment assignment, BlockScope scope) {
72 // do nothing by default
74 public void endVisit(BinaryExpression binaryExpression, BlockScope scope) {
75 // do nothing by default
77 public void endVisit(Block block, BlockScope scope) {
78 // do nothing by default
80 public void endVisit(BreakStatement breakStatement, BlockScope scope) {
81 // do nothing by default
83 public void endVisit(CaseStatement caseStatement, BlockScope scope) {
84 // do nothing by default
86 public void endVisit(CastExpression castExpression, BlockScope scope) {
87 // do nothing by default
89 public void endVisit(CharLiteral charLiteral, BlockScope scope) {
90 // do nothing by default
92 public void endVisit(ClassLiteralAccess classLiteral, BlockScope scope) {
93 // do nothing by default
95 public void endVisit(Clinit clinit, ClassScope scope) {
96 // do nothing by default
99 CompilationUnitDeclaration compilationUnitDeclaration,
100 CompilationUnitScope scope) {
101 // do nothing by default
103 public void endVisit(CompoundAssignment compoundAssignment, BlockScope scope) {
104 // do nothing by default
106 public void endVisit(
107 ConditionalExpression conditionalExpression,
109 // do nothing by default
111 public void endVisit(
112 ConstructorDeclaration constructorDeclaration,
114 // do nothing by default
116 public void endVisit(ContinueStatement continueStatement, BlockScope scope) {
117 // do nothing by default
119 public void endVisit(DoStatement doStatement, BlockScope scope) {
120 // do nothing by default
122 public void endVisit(DoubleLiteral doubleLiteral, BlockScope scope) {
123 // do nothing by default
125 public void endVisit(EmptyStatement emptyStatement, BlockScope scope) {
126 // do nothing by default
128 public void endVisit(EqualExpression equalExpression, BlockScope scope) {
129 // do nothing by default
131 public void endVisit(
132 ExplicitConstructorCall explicitConstructor,
134 // do nothing by default
136 public void endVisit(
137 ExtendedStringLiteral extendedStringLiteral,
139 // do nothing by default
141 public void endVisit(FalseLiteral falseLiteral, BlockScope scope) {
142 // do nothing by default
144 public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
145 // do nothing by default
147 public void endVisit(FieldReference fieldReference, BlockScope scope) {
148 // do nothing by default
150 public void endVisit(FloatLiteral floatLiteral, BlockScope scope) {
151 // do nothing by default
153 public void endVisit(ForeachStatement forStatement, BlockScope scope) {
154 // do nothing by default
156 public void endVisit(ForStatement forStatement, BlockScope scope) {
157 // do nothing by default
159 public void endVisit(IfStatement ifStatement, BlockScope scope) {
160 // do nothing by default
162 public void endVisit(ImportReference importRef, CompilationUnitScope scope) {
163 // do nothing by default
165 public void endVisit(Initializer initializer, MethodScope scope) {
166 // do nothing by default
168 public void endVisit(
169 InstanceOfExpression instanceOfExpression,
171 // do nothing by default
173 public void endVisit(IntLiteral intLiteral, BlockScope scope) {
174 // do nothing by default
176 public void endVisit(JavadocArgumentExpression expression, BlockScope scope) {
177 // do nothing by default
179 public void endVisit(JavadocArrayQualifiedTypeReference typeRef, BlockScope scope) {
180 // do nothing by default
182 public void endVisit(JavadocArraySingleTypeReference typeRef, BlockScope scope) {
183 // do nothing by default
185 public void endVisit(JavadocFieldReference fieldRef, BlockScope scope) {
186 // do nothing by default
188 public void endVisit(JavadocMessageSend messageSend, BlockScope scope) {
189 // do nothing by default
191 public void endVisit(JavadocQualifiedTypeReference typeRef, BlockScope scope) {
192 // do nothing by default
194 public void endVisit(JavadocReturnStatement statement, BlockScope scope) {
195 // do nothing by default
197 public void endVisit(JavadocSingleNameReference argument, BlockScope scope) {
198 // do nothing by default
200 public void endVisit(JavadocSingleTypeReference typeRef, BlockScope scope) {
201 // do nothing by default
203 public void endVisit(LabeledStatement labeledStatement, BlockScope scope) {
204 // do nothing by default
206 public void endVisit(LocalDeclaration localDeclaration, BlockScope scope) {
207 // do nothing by default
209 public void endVisit(LongLiteral longLiteral, BlockScope scope) {
210 // do nothing by default
217 public void endVisit(MarkerAnnotation annotation, BlockScope scope) {
218 // do nothing by default
225 public void endVisit(MarkerAnnotation annotation, CompilationUnitScope scope) {
226 // do nothing by default
232 public void endVisit(MemberValuePair pair, BlockScope scope) {
233 // do nothing by default
239 public void endVisit(MemberValuePair pair, CompilationUnitScope scope) {
240 // do nothing by default
242 public void endVisit(MessageSend messageSend, BlockScope scope) {
243 // do nothing by default
245 public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
246 // do nothing by default
248 public void endVisit(StringLiteralConcatenation literal, BlockScope scope) {
249 // do nothing by default
256 public void endVisit(NormalAnnotation annotation, BlockScope scope) {
257 // do nothing by default
264 public void endVisit(NormalAnnotation annotation, CompilationUnitScope scope) {
265 // do nothing by default
267 public void endVisit(NullLiteral nullLiteral, BlockScope scope) {
268 // do nothing by default
270 public void endVisit(OR_OR_Expression or_or_Expression, BlockScope scope) {
271 // do nothing by default
273 public void endVisit(ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference, BlockScope scope) {
274 // do nothing by default
276 public void endVisit(ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference, ClassScope scope) {
277 // do nothing by default
279 public void endVisit(ParameterizedSingleTypeReference parameterizedSingleTypeReference, BlockScope scope) {
280 // do nothing by default
282 public void endVisit(ParameterizedSingleTypeReference parameterizedSingleTypeReference, ClassScope scope) {
283 // do nothing by default
285 public void endVisit(PostfixExpression postfixExpression, BlockScope scope) {
286 // do nothing by default
288 public void endVisit(PrefixExpression prefixExpression, BlockScope scope) {
289 // do nothing by default
291 public void endVisit(
292 QualifiedAllocationExpression qualifiedAllocationExpression,
294 // do nothing by default
296 public void endVisit(
297 QualifiedNameReference qualifiedNameReference,
299 // do nothing by default
301 public void endVisit(
302 QualifiedSuperReference qualifiedSuperReference,
304 // do nothing by default
306 public void endVisit(
307 QualifiedThisReference qualifiedThisReference,
309 // do nothing by default
311 public void endVisit(
312 QualifiedTypeReference qualifiedTypeReference,
314 // do nothing by default
316 public void endVisit(
317 QualifiedTypeReference qualifiedTypeReference,
319 // do nothing by default
321 public void endVisit(ReturnStatement returnStatement, BlockScope scope) {
322 // do nothing by default
329 public void endVisit(SingleMemberAnnotation annotation, BlockScope scope) {
330 // do nothing by default
337 public void endVisit(SingleMemberAnnotation annotation, CompilationUnitScope scope) {
338 // do nothing by default
340 public void endVisit(
341 SingleNameReference singleNameReference,
343 // do nothing by default
345 public void endVisit(
346 SingleTypeReference singleTypeReference,
348 // do nothing by default
350 public void endVisit(
351 SingleTypeReference singleTypeReference,
353 // do nothing by default
355 public void endVisit(StringLiteral stringLiteral, BlockScope scope) {
356 // do nothing by default
358 public void endVisit(SuperReference superReference, BlockScope scope) {
359 // do nothing by default
361 public void endVisit(SwitchStatement switchStatement, BlockScope scope) {
362 // do nothing by default
364 public void endVisit(
365 SynchronizedStatement synchronizedStatement,
367 // do nothing by default
369 public void endVisit(ThisReference thisReference, BlockScope scope) {
370 // do nothing by default
372 public void endVisit(ThrowStatement throwStatement, BlockScope scope) {
373 // do nothing by default
375 public void endVisit(TrueLiteral trueLiteral, BlockScope scope) {
376 // do nothing by default
378 public void endVisit(TryStatement tryStatement, BlockScope scope) {
379 // do nothing by default
381 public void endVisit(
382 TypeDeclaration localTypeDeclaration,
384 // do nothing by default
386 public void endVisit(
387 TypeDeclaration memberTypeDeclaration,
389 // do nothing by default
391 public void endVisit(
392 TypeDeclaration typeDeclaration,
393 CompilationUnitScope scope) {
394 // do nothing by default
396 public void endVisit(TypeParameter typeParameter, BlockScope scope) {
397 // do nothing by default
399 public void endVisit(TypeParameter typeParameter, ClassScope scope) {
400 // do nothing by default
402 public void endVisit(UnaryExpression unaryExpression, BlockScope scope) {
403 // do nothing by default
405 public void endVisit(WhileStatement whileStatement, BlockScope scope) {
406 // do nothing by default
408 public void endVisit(Wildcard wildcard, BlockScope scope) {
409 // do nothing by default
411 public void endVisit(Wildcard wildcard, ClassScope scope) {
412 // do nothing by default
414 public boolean visit(
415 AllocationExpression allocationExpression,
417 return true; // do nothing by default, keep traversing
419 public boolean visit(AND_AND_Expression and_and_Expression, BlockScope scope) {
420 return true; // do nothing by default, keep traversing
422 public boolean visit(
423 AnnotationMethodDeclaration annotationTypeDeclaration,
424 ClassScope classScope) {
425 return true; // do nothing by default, keep traversing
427 public boolean visit(Argument argument, BlockScope scope) {
428 return true; // do nothing by default, keep traversing
430 public boolean visit(
431 ArrayAllocationExpression arrayAllocationExpression,
433 return true; // do nothing by default, keep traversing
435 public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
436 return true; // do nothing by default, keep traversing
438 public boolean visit(
439 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
441 return true; // do nothing by default, keep traversing
443 public boolean visit(
444 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
446 return true; // do nothing by default, keep traversing
448 public boolean visit(ArrayReference arrayReference, BlockScope scope) {
449 return true; // do nothing by default, keep traversing
451 public boolean visit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
452 return true; // do nothing by default, keep traversing
454 public boolean visit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
455 return true; // do nothing by default, keep traversing
457 public boolean visit(AssertStatement assertStatement, BlockScope scope) {
458 return true; // do nothing by default, keep traversing
460 public boolean visit(Assignment assignment, BlockScope scope) {
461 return true; // do nothing by default, keep traversing
463 public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
464 return true; // do nothing by default, keep traversing
466 public boolean visit(Block block, BlockScope scope) {
467 return true; // do nothing by default, keep traversing
469 public boolean visit(BreakStatement breakStatement, BlockScope scope) {
470 return true; // do nothing by default, keep traversing
472 public boolean visit(CaseStatement caseStatement, BlockScope scope) {
473 return true; // do nothing by default, keep traversing
475 public boolean visit(CastExpression castExpression, BlockScope scope) {
476 return true; // do nothing by default, keep traversing
478 public boolean visit(CharLiteral charLiteral, BlockScope scope) {
479 return true; // do nothing by default, keep traversing
481 public boolean visit(ClassLiteralAccess classLiteral, BlockScope scope) {
482 return true; // do nothing by default, keep traversing
484 public boolean visit(Clinit clinit, ClassScope scope) {
485 return true; // do nothing by default, keep traversing
487 public boolean visit(
488 CompilationUnitDeclaration compilationUnitDeclaration,
489 CompilationUnitScope scope) {
490 return true; // do nothing by default, keep traversing
492 public boolean visit(CompoundAssignment compoundAssignment, BlockScope scope) {
493 return true; // do nothing by default, keep traversing
495 public boolean visit(
496 ConditionalExpression conditionalExpression,
498 return true; // do nothing by default, keep traversing
500 public boolean visit(
501 ConstructorDeclaration constructorDeclaration,
503 return true; // do nothing by default, keep traversing
505 public boolean visit(ContinueStatement continueStatement, BlockScope scope) {
506 return true; // do nothing by default, keep traversing
508 public boolean visit(DoStatement doStatement, BlockScope scope) {
509 return true; // do nothing by default, keep traversing
511 public boolean visit(DoubleLiteral doubleLiteral, BlockScope scope) {
512 return true; // do nothing by default, keep traversing
514 public boolean visit(EmptyStatement emptyStatement, BlockScope scope) {
515 return true; // do nothing by default, keep traversing
517 public boolean visit(EqualExpression equalExpression, BlockScope scope) {
518 return true; // do nothing by default, keep traversing
520 public boolean visit(
521 ExplicitConstructorCall explicitConstructor,
523 return true; // do nothing by default, keep traversing
525 public boolean visit(
526 ExtendedStringLiteral extendedStringLiteral,
528 return true; // do nothing by default, keep traversing
530 public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
531 return true; // do nothing by default, keep traversing
533 public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
534 return true; // do nothing by default, keep traversing
536 public boolean visit(FieldReference fieldReference, BlockScope scope) {
537 return true; // do nothing by default, keep traversing
539 public boolean visit(FloatLiteral floatLiteral, BlockScope scope) {
540 return true; // do nothing by default, keep traversing
542 public boolean visit(ForeachStatement forStatement, BlockScope scope) {
543 return true; // do nothing by default, keep traversing
545 public boolean visit(ForStatement forStatement, BlockScope scope) {
546 return true; // do nothing by default, keep traversing
548 public boolean visit(IfStatement ifStatement, BlockScope scope) {
549 return true; // do nothing by default, keep traversing
551 public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
552 return true; // do nothing by default, keep traversing
554 public boolean visit(Initializer initializer, MethodScope scope) {
555 return true; // do nothing by default, keep traversing
557 public boolean visit(
558 InstanceOfExpression instanceOfExpression,
560 return true; // do nothing by default, keep traversing
562 public boolean visit(IntLiteral intLiteral, BlockScope scope) {
563 return true; // do nothing by default, keep traversing
565 public boolean visit(JavadocArgumentExpression expression, BlockScope scope) {
566 return true; // do nothing by default, keep traversing
568 public boolean visit(JavadocArrayQualifiedTypeReference typeRef, BlockScope scope) {
569 return true; // do nothing by default, keep traversing
571 public boolean visit(JavadocArraySingleTypeReference typeRef, BlockScope scope) {
572 return true; // do nothing by default, keep traversing
574 public boolean visit(JavadocFieldReference fieldRef, BlockScope scope) {
575 return true; // do nothing by default, keep traversing
577 public boolean visit(JavadocMessageSend messageSend, BlockScope scope) {
578 return true; // do nothing by default, keep traversing
580 public boolean visit(JavadocQualifiedTypeReference typeRef, BlockScope scope) {
581 return true; // do nothing by default, keep traversing
583 public boolean visit(JavadocReturnStatement statement, BlockScope scope) {
584 return true; // do nothing by default, keep traversing
586 public boolean visit(JavadocSingleNameReference argument, BlockScope scope) {
587 return true; // do nothing by default, keep traversing
589 public boolean visit(JavadocSingleTypeReference typeRef, BlockScope scope) {
590 return true; // do nothing by default, keep traversing
592 public boolean visit(LabeledStatement labeledStatement, BlockScope scope) {
593 return true; // do nothing by default, keep traversing
595 public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
596 return true; // do nothing by default, keep traversing
598 public boolean visit(LongLiteral longLiteral, BlockScope scope) {
599 return true; // do nothing by default, keep traversing
606 public boolean visit(MarkerAnnotation annotation, BlockScope scope) {
614 public boolean visit(MarkerAnnotation annotation, CompilationUnitScope scope) {
622 public boolean visit(MemberValuePair pair, BlockScope scope) {
630 public boolean visit(MemberValuePair pair, CompilationUnitScope scope) {
633 public boolean visit(MessageSend messageSend, BlockScope scope) {
634 return true; // do nothing by default, keep traversing
636 public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
637 return true; // do nothing by default, keep traversing
639 public boolean visit(
640 StringLiteralConcatenation literal,
642 return true; // do nothing by default, keep traversing
649 public boolean visit(NormalAnnotation annotation, BlockScope scope) {
657 public boolean visit(NormalAnnotation annotation, CompilationUnitScope scope) {
660 public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
661 return true; // do nothing by default, keep traversing
663 public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
664 return true; // do nothing by default, keep traversing
666 public boolean visit(ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference, BlockScope scope) {
667 return true; // do nothing by default, keep traversing
669 public boolean visit(ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference, ClassScope scope) {
670 return true; // do nothing by default, keep traversing
672 public boolean visit(ParameterizedSingleTypeReference parameterizedSingleTypeReference, BlockScope scope) {
673 return true; // do nothing by default, keep traversing
675 public boolean visit(ParameterizedSingleTypeReference parameterizedSingleTypeReference, ClassScope scope) {
676 return true; // do nothing by default, keep traversing
678 public boolean visit(PostfixExpression postfixExpression, BlockScope scope) {
679 return true; // do nothing by default, keep traversing
681 public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
682 return true; // do nothing by default, keep traversing
684 public boolean visit(
685 QualifiedAllocationExpression qualifiedAllocationExpression,
687 return true; // do nothing by default, keep traversing
689 public boolean visit(
690 QualifiedNameReference qualifiedNameReference,
692 return true; // do nothing by default, keep traversing
694 public boolean visit(
695 QualifiedSuperReference qualifiedSuperReference,
697 return true; // do nothing by default, keep traversing
699 public boolean visit(
700 QualifiedThisReference qualifiedThisReference,
702 return true; // do nothing by default, keep traversing
704 public boolean visit(
705 QualifiedTypeReference qualifiedTypeReference,
707 return true; // do nothing by default, keep traversing
709 public boolean visit(
710 QualifiedTypeReference qualifiedTypeReference,
712 return true; // do nothing by default, keep traversing
714 public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
715 return true; // do nothing by default, keep traversing
722 public boolean visit(SingleMemberAnnotation annotation, BlockScope scope) {
730 public boolean visit(SingleMemberAnnotation annotation, CompilationUnitScope scope) {
733 public boolean visit(
734 SingleNameReference singleNameReference,
736 return true; // do nothing by default, keep traversing
738 public boolean visit(
739 SingleTypeReference singleTypeReference,
741 return true; // do nothing by default, keep traversing
743 public boolean visit(
744 SingleTypeReference singleTypeReference,
746 return true; // do nothing by default, keep traversing
748 public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
749 return true; // do nothing by default, keep traversing
751 public boolean visit(SuperReference superReference, BlockScope scope) {
752 return true; // do nothing by default, keep traversing
754 public boolean visit(SwitchStatement switchStatement, BlockScope scope) {
755 return true; // do nothing by default, keep traversing
757 public boolean visit(
758 SynchronizedStatement synchronizedStatement,
760 return true; // do nothing by default, keep traversing
762 public boolean visit(ThisReference thisReference, BlockScope scope) {
763 return true; // do nothing by default, keep traversing
765 public boolean visit(ThrowStatement throwStatement, BlockScope scope) {
766 return true; // do nothing by default, keep traversing
768 public boolean visit(TrueLiteral trueLiteral, BlockScope scope) {
769 return true; // do nothing by default, keep traversing
771 public boolean visit(TryStatement tryStatement, BlockScope scope) {
772 return true; // do nothing by default, keep traversing
774 public boolean visit(
775 TypeDeclaration localTypeDeclaration,
777 return true; // do nothing by default, keep traversing
779 public boolean visit(
780 TypeDeclaration memberTypeDeclaration,
782 return true; // do nothing by default, keep traversing
784 public boolean visit(
785 TypeDeclaration typeDeclaration,
786 CompilationUnitScope scope) {
787 return true; // do nothing by default, keep traversing
789 public boolean visit(TypeParameter typeParameter, BlockScope scope) {
790 return true; // do nothing by default, keep traversing
792 public boolean visit(TypeParameter typeParameter, ClassScope scope) {
793 return true; // do nothing by default, keep traversing
795 public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
796 return true; // do nothing by default, keep traversing
798 public boolean visit(WhileStatement whileStatement, BlockScope scope) {
799 return true; // do nothing by default, keep traversing
801 public boolean visit(Wildcard wildcard, BlockScope scope) {
802 return true; // do nothing by default, keep traversing
804 public boolean visit(Wildcard wildcard, ClassScope scope) {
805 return true; // do nothing by default, keep traversing