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 net.sourceforge.phpdt.internal.compiler;
13 import net.sourceforge.phpdt.core.compiler.*;
14 import net.sourceforge.phpeclipse.internal.compiler.ast.*;
15 import net.sourceforge.phpdt.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
33 // public void endVisit(JavadocArrayQualifiedTypeReference typeRef, BlockScope scope) {
34 // // do nothing by default
36 // public void endVisit(JavadocArraySingleTypeReference typeRef, BlockScope scope) {
37 // // do nothing by default
39 // public void endVisit(JavadocArgumentExpression expression, BlockScope scope) {
40 // // do nothing by default
42 // public void endVisit(JavadocFieldReference fieldRef, BlockScope scope) {
43 // // do nothing by default
45 // public void endVisit(JavadocMessageSend messageSend, BlockScope scope) {
46 // // do nothing by default
48 // public void endVisit(JavadocQualifiedTypeReference typeRef, BlockScope scope) {
49 // // do nothing by default
51 // public void endVisit(JavadocReturnStatement statement, BlockScope scope) {
52 // // do nothing by default
54 // public void endVisit(JavadocSingleNameReference argument, BlockScope scope) {
55 // // do nothing by default
57 // public void endVisit(JavadocSingleTypeReference typeRef, BlockScope scope) {
58 // // do nothing by default
60 public void endVisit(Argument argument, BlockScope scope) {
61 // do nothing by default
64 ArrayAllocationExpression arrayAllocationExpression,
66 // do nothing by default
68 public void endVisit(ArrayInitializer arrayInitializer, BlockScope scope) {
69 // do nothing by default
72 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
74 // do nothing by default
77 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
79 // do nothing by default
81 public void endVisit(ArrayReference arrayReference, BlockScope scope) {
82 // do nothing by default
84 public void endVisit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
85 // do nothing by default
87 public void endVisit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
88 // do nothing by default
90 public void endVisit(Assignment assignment, BlockScope scope) {
91 // do nothing by default
93 public void endVisit(AssertStatement assertStatement, BlockScope scope) {
94 // do nothing by default
96 public void endVisit(BinaryExpression binaryExpression, BlockScope scope) {
97 // do nothing by default
99 public void endVisit(Block block, BlockScope scope) {
100 // do nothing by default
102 public void endVisit(Break breakStatement, BlockScope scope) {
103 // do nothing by default
105 public void endVisit(Case caseStatement, BlockScope scope) {
106 // do nothing by default
108 public void endVisit(CastExpression castExpression, BlockScope scope) {
109 // do nothing by default
111 public void endVisit(CharLiteral charLiteral, BlockScope scope) {
112 // do nothing by default
114 public void endVisit(ClassLiteralAccess classLiteral, BlockScope scope) {
115 // do nothing by default
117 public void endVisit(Clinit clinit, ClassScope scope) {
118 // do nothing by default
120 public void endVisit(
121 CompilationUnitDeclaration compilationUnitDeclaration,
122 CompilationUnitScope scope) {
123 // do nothing by default
125 public void endVisit(CompoundAssignment compoundAssignment, BlockScope scope) {
126 // do nothing by default
128 public void endVisit(
129 ConditionalExpression conditionalExpression,
131 // do nothing by default
133 public void endVisit(
134 ConstructorDeclaration constructorDeclaration,
136 // do nothing by default
138 public void endVisit(Continue continueStatement, BlockScope scope) {
139 // do nothing by default
141 public void endVisit(DoStatement doStatement, BlockScope scope) {
142 // do nothing by default
144 public void endVisit(DoubleLiteral doubleLiteral, BlockScope scope) {
145 // do nothing by default
147 public void endVisit(EqualExpression equalExpression, BlockScope scope) {
148 // do nothing by default
150 public void endVisit(
151 ExplicitConstructorCall explicitConstructor,
153 // do nothing by default
155 public void endVisit(
156 ExtendedStringLiteral extendedStringLiteral,
158 // do nothing by default
160 public void endVisit(FalseLiteral falseLiteral, BlockScope scope) {
161 // do nothing by default
163 public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
164 // do nothing by default
166 public void endVisit(FieldReference fieldReference, BlockScope scope) {
167 // do nothing by default
169 public void endVisit(FloatLiteral floatLiteral, BlockScope scope) {
170 // do nothing by default
172 public void endVisit(EmptyStatement emptyStatement, BlockScope scope) {
173 // do nothing by default
175 public void endVisit(ForStatement forStatement, BlockScope scope) {
176 // do nothing by default
178 public void endVisit(IfStatement ifStatement, BlockScope scope) {
179 // do nothing by default
181 public void endVisit(ImportReference importRef, CompilationUnitScope scope) {
182 // do nothing by default
184 public void endVisit(Initializer initializer, MethodScope scope) {
185 // do nothing by default
187 public void endVisit(
188 InstanceOfExpression instanceOfExpression,
190 // do nothing by default
192 public void endVisit(IntLiteral intLiteral, BlockScope scope) {
193 // do nothing by default
195 public void endVisit(LabeledStatement labeledStatement, BlockScope scope) {
196 // do nothing by default
198 public void endVisit(LocalDeclaration localDeclaration, BlockScope scope) {
199 // do nothing by default
201 public void endVisit(LongLiteral longLiteral, BlockScope scope) {
202 // do nothing by default
204 public void endVisit(MessageSend messageSend, BlockScope scope) {
205 // do nothing by default
207 public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
208 // do nothing by default
210 // public void endVisit(StringLiteralConcatenation literal, BlockScope scope) {
211 // // do nothing by default
213 public void endVisit(NullLiteral nullLiteral, BlockScope scope) {
214 // do nothing by default
216 public void endVisit(OR_OR_Expression or_or_Expression, BlockScope scope) {
217 // do nothing by default
219 public void endVisit(PostfixExpression postfixExpression, BlockScope scope) {
220 // do nothing by default
222 public void endVisit(PrefixExpression prefixExpression, BlockScope scope) {
223 // do nothing by default
225 public void endVisit(
226 QualifiedAllocationExpression qualifiedAllocationExpression,
228 // do nothing by default
230 public void endVisit(
231 QualifiedNameReference qualifiedNameReference,
233 // do nothing by default
235 public void endVisit(
236 QualifiedSuperReference qualifiedSuperReference,
238 // do nothing by default
240 public void endVisit(
241 QualifiedThisReference qualifiedThisReference,
243 // do nothing by default
245 public void endVisit(
246 QualifiedTypeReference qualifiedTypeReference,
248 // do nothing by default
250 public void endVisit(
251 QualifiedTypeReference qualifiedTypeReference,
253 // do nothing by default
255 public void endVisit(ReturnStatement returnStatement, BlockScope scope) {
256 // do nothing by default
258 public void endVisit(
259 SingleNameReference singleNameReference,
261 // do nothing by default
263 public void endVisit(
264 SingleTypeReference singleTypeReference,
266 // do nothing by default
268 public void endVisit(
269 SingleTypeReference singleTypeReference,
271 // do nothing by default
273 public void endVisit(StringLiteral stringLiteral, BlockScope scope) {
274 // do nothing by default
276 public void endVisit(SuperReference superReference, BlockScope scope) {
277 // do nothing by default
279 public void endVisit(SwitchStatement switchStatement, BlockScope scope) {
280 // do nothing by default
282 public void endVisit(
283 SynchronizedStatement synchronizedStatement,
285 // do nothing by default
287 public void endVisit(ThisReference thisReference, BlockScope scope) {
288 // do nothing by default
290 public void endVisit(ThrowStatement throwStatement, BlockScope scope) {
291 // do nothing by default
293 public void endVisit(TrueLiteral trueLiteral, BlockScope scope) {
294 // do nothing by default
296 public void endVisit(TryStatement tryStatement, BlockScope scope) {
297 // do nothing by default
299 public void endVisit(
300 TypeDeclaration localTypeDeclaration,
302 // do nothing by default
304 public void endVisit(
305 TypeDeclaration memberTypeDeclaration,
307 // do nothing by default
309 public void endVisit(
310 TypeDeclaration typeDeclaration,
311 CompilationUnitScope scope) {
312 // do nothing by default
314 public void endVisit(UnaryExpression unaryExpression, BlockScope scope) {
315 // do nothing by default
317 public void endVisit(WhileStatement whileStatement, BlockScope scope) {
318 // do nothing by default
320 public boolean visit(
321 AllocationExpression allocationExpression,
323 return true; // do nothing by default, keep traversing
324 // do nothing by default
326 public boolean visit(AND_AND_Expression and_and_Expression, BlockScope scope) {
327 return true; // do nothing by default, keep traversing
329 // public boolean visit(JavadocArrayQualifiedTypeReference typeRef, BlockScope scope) {
330 // return true; // do nothing by default, keep traversing
332 // public boolean visit(JavadocArraySingleTypeReference typeRef, BlockScope scope) {
333 // return true; // do nothing by default, keep traversing
335 // public boolean visit(JavadocArgumentExpression expression, BlockScope scope) {
336 // return true; // do nothing by default, keep traversing
338 // public boolean visit(JavadocFieldReference fieldRef, BlockScope scope) {
339 // return true; // do nothing by default, keep traversing
341 // public boolean visit(JavadocMessageSend messageSend, BlockScope scope) {
342 // return true; // do nothing by default, keep traversing
344 // public boolean visit(JavadocQualifiedTypeReference typeRef, BlockScope scope) {
345 // return true; // do nothing by default, keep traversing
347 // public boolean visit(JavadocReturnStatement statement, BlockScope scope) {
348 // return true; // do nothing by default, keep traversing
350 // public boolean visit(JavadocSingleNameReference argument, BlockScope scope) {
351 // return true; // do nothing by default, keep traversing
353 // public boolean visit(JavadocSingleTypeReference typeRef, BlockScope scope) {
354 // return true; // do nothing by default, keep traversing
356 public boolean visit(Argument argument, BlockScope scope) {
357 return true; // do nothing by default, keep traversing
359 public boolean visit(
360 ArrayAllocationExpression arrayAllocationExpression,
362 return true; // do nothing by default, keep traversing
364 public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
365 return true; // do nothing by default, keep traversing
367 public boolean visit(
368 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
370 return true; // do nothing by default, keep traversing
372 public boolean visit(
373 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
375 return true; // do nothing by default, keep traversing
377 public boolean visit(ArrayReference arrayReference, BlockScope scope) {
378 return true; // do nothing by default, keep traversing
380 public boolean visit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
381 return true; // do nothing by default, keep traversing
383 public boolean visit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
384 return true; // do nothing by default, keep traversing
386 public boolean visit(Assignment assignment, BlockScope scope) {
387 return true; // do nothing by default, keep traversing
389 public boolean visit(AssertStatement assertStatement, BlockScope scope) {
390 return true; // do nothing by default, keep traversing
392 public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
393 return true; // do nothing by default, keep traversing
395 public boolean visit(Block block, BlockScope scope) {
396 return true; // do nothing by default, keep traversing
398 public boolean visit(Break breakStatement, BlockScope scope) {
399 return true; // do nothing by default, keep traversing
401 public boolean visit(Case caseStatement, BlockScope scope) {
402 return true; // do nothing by default, keep traversing
404 public boolean visit(CastExpression castExpression, BlockScope scope) {
405 return true; // do nothing by default, keep traversing
407 public boolean visit(CharLiteral charLiteral, BlockScope scope) {
408 return true; // do nothing by default, keep traversing
410 public boolean visit(ClassLiteralAccess classLiteral, BlockScope scope) {
411 return true; // do nothing by default, keep traversing
413 public boolean visit(Clinit clinit, ClassScope scope) {
414 return true; // do nothing by default, keep traversing
416 public boolean visit(
417 CompilationUnitDeclaration compilationUnitDeclaration,
418 CompilationUnitScope scope) {
419 return true; // do nothing by default, keep traversing
421 public boolean visit(CompoundAssignment compoundAssignment, BlockScope scope) {
422 return true; // do nothing by default, keep traversing
424 public boolean visit(
425 ConditionalExpression conditionalExpression,
427 return true; // do nothing by default, keep traversing
429 public boolean visit(
430 ConstructorDeclaration constructorDeclaration,
432 return true; // do nothing by default, keep traversing
434 public boolean visit(Continue continueStatement, BlockScope scope) {
435 return true; // do nothing by default, keep traversing
437 public boolean visit(DoStatement doStatement, BlockScope scope) {
438 return true; // do nothing by default, keep traversing
440 public boolean visit(DoubleLiteral doubleLiteral, BlockScope scope) {
441 return true; // do nothing by default, keep traversing
443 public boolean visit(EqualExpression equalExpression, BlockScope scope) {
444 return true; // do nothing by default, keep traversing
446 public boolean visit(EmptyStatement emptyStatement, BlockScope scope) {
447 return true; // do nothing by default, keep traversing
449 public boolean visit(
450 ExplicitConstructorCall explicitConstructor,
452 return true; // do nothing by default, keep traversing
454 public boolean visit(
455 ExtendedStringLiteral extendedStringLiteral,
457 return true; // do nothing by default, keep traversing
459 public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
460 return true; // do nothing by default, keep traversing
462 public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
463 return true; // do nothing by default, keep traversing
465 public boolean visit(FieldReference fieldReference, BlockScope scope) {
466 return true; // do nothing by default, keep traversing
468 public boolean visit(FloatLiteral floatLiteral, BlockScope scope) {
469 return true; // do nothing by default, keep traversing
471 public boolean visit(ForStatement forStatement, BlockScope scope) {
472 return true; // do nothing by default, keep traversing
474 public boolean visit(IfStatement ifStatement, BlockScope scope) {
475 return true; // do nothing by default, keep traversing
477 public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
478 return true; // do nothing by default, keep traversing
480 public boolean visit(Initializer initializer, MethodScope scope) {
481 return true; // do nothing by default, keep traversing
483 public boolean visit(
484 InstanceOfExpression instanceOfExpression,
486 return true; // do nothing by default, keep traversing
488 public boolean visit(IntLiteral intLiteral, BlockScope scope) {
489 return true; // do nothing by default, keep traversing
491 public boolean visit(LabeledStatement labeledStatement, BlockScope scope) {
492 return true; // do nothing by default, keep traversing
494 public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
495 return true; // do nothing by default, keep traversing
497 public boolean visit(LongLiteral longLiteral, BlockScope scope) {
498 return true; // do nothing by default, keep traversing
500 public boolean visit(MessageSend messageSend, BlockScope scope) {
501 return true; // do nothing by default, keep traversing
503 public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
504 return true; // do nothing by default, keep traversing
506 // public boolean visit(
507 // StringLiteralConcatenation literal,
508 // BlockScope scope) {
509 // return true; // do nothing by default, keep traversing
511 public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
512 return true; // do nothing by default, keep traversing
514 public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
515 return true; // do nothing by default, keep traversing
517 public boolean visit(PostfixExpression postfixExpression, BlockScope scope) {
518 return true; // do nothing by default, keep traversing
520 public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
521 return true; // do nothing by default, keep traversing
523 public boolean visit(
524 QualifiedAllocationExpression qualifiedAllocationExpression,
526 return true; // do nothing by default, keep traversing
528 public boolean visit(
529 QualifiedNameReference qualifiedNameReference,
531 return true; // do nothing by default, keep traversing
533 public boolean visit(
534 QualifiedSuperReference qualifiedSuperReference,
536 return true; // do nothing by default, keep traversing
538 public boolean visit(
539 QualifiedThisReference qualifiedThisReference,
541 return true; // do nothing by default, keep traversing
543 public boolean visit(
544 QualifiedTypeReference qualifiedTypeReference,
546 return true; // do nothing by default, keep traversing
548 public boolean visit(
549 QualifiedTypeReference qualifiedTypeReference,
551 return true; // do nothing by default, keep traversing
553 public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
554 return true; // do nothing by default, keep traversing
556 public boolean visit(
557 SingleNameReference singleNameReference,
559 return true; // do nothing by default, keep traversing
561 public boolean visit(
562 SingleTypeReference singleTypeReference,
564 return true; // do nothing by default, keep traversing
566 public boolean visit(
567 SingleTypeReference singleTypeReference,
569 return true; // do nothing by default, keep traversing
571 public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
572 return true; // do nothing by default, keep traversing
574 public boolean visit(SuperReference superReference, BlockScope scope) {
575 return true; // do nothing by default, keep traversing
577 public boolean visit(SwitchStatement switchStatement, BlockScope scope) {
578 return true; // do nothing by default, keep traversing
580 public boolean visit(
581 SynchronizedStatement synchronizedStatement,
583 return true; // do nothing by default, keep traversing
585 public boolean visit(ThisReference thisReference, BlockScope scope) {
586 return true; // do nothing by default, keep traversing
588 public boolean visit(ThrowStatement throwStatement, BlockScope scope) {
589 return true; // do nothing by default, keep traversing
591 public boolean visit(TrueLiteral trueLiteral, BlockScope scope) {
592 return true; // do nothing by default, keep traversing
594 public boolean visit(TryStatement tryStatement, BlockScope scope) {
595 return true; // do nothing by default, keep traversing
597 public boolean visit(
598 TypeDeclaration localTypeDeclaration,
600 return true; // do nothing by default, keep traversing
602 public boolean visit(
603 TypeDeclaration memberTypeDeclaration,
605 return true; // do nothing by default, keep traversing
607 public boolean visit(
608 TypeDeclaration typeDeclaration,
609 CompilationUnitScope scope) {
610 return true; // do nothing by default, keep traversing
612 public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
613 return true; // do nothing by default, keep traversing
615 public boolean visit(WhileStatement whileStatement, BlockScope scope) {
616 return true; // do nothing by default, keep traversing