1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 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.IProblem;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.MethodScope;
18 import net.sourceforge.phpeclipse.internal.compiler.ast.AND_AND_Expression;
19 import net.sourceforge.phpeclipse.internal.compiler.ast.AllocationExpression;
20 import net.sourceforge.phpeclipse.internal.compiler.ast.AnonymousLocalTypeDeclaration;
21 import net.sourceforge.phpeclipse.internal.compiler.ast.Argument;
22 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayAllocationExpression;
23 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayInitializer;
24 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayQualifiedTypeReference;
25 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayReference;
26 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayTypeReference;
27 import net.sourceforge.phpeclipse.internal.compiler.ast.AssertStatement;
28 import net.sourceforge.phpeclipse.internal.compiler.ast.Assignment;
29 import net.sourceforge.phpeclipse.internal.compiler.ast.BinaryExpression;
30 import net.sourceforge.phpeclipse.internal.compiler.ast.Block;
31 import net.sourceforge.phpeclipse.internal.compiler.ast.Break;
32 import net.sourceforge.phpeclipse.internal.compiler.ast.Case;
33 import net.sourceforge.phpeclipse.internal.compiler.ast.CastExpression;
34 import net.sourceforge.phpeclipse.internal.compiler.ast.CharLiteral;
35 import net.sourceforge.phpeclipse.internal.compiler.ast.ClassLiteralAccess;
36 import net.sourceforge.phpeclipse.internal.compiler.ast.Clinit;
37 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
38 import net.sourceforge.phpeclipse.internal.compiler.ast.CompoundAssignment;
39 import net.sourceforge.phpeclipse.internal.compiler.ast.ConditionalExpression;
40 import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration;
41 import net.sourceforge.phpeclipse.internal.compiler.ast.Continue;
42 import net.sourceforge.phpeclipse.internal.compiler.ast.DefaultCase;
43 import net.sourceforge.phpeclipse.internal.compiler.ast.DoStatement;
44 import net.sourceforge.phpeclipse.internal.compiler.ast.DoubleLiteral;
45 import net.sourceforge.phpeclipse.internal.compiler.ast.EmptyStatement;
46 import net.sourceforge.phpeclipse.internal.compiler.ast.EqualExpression;
47 import net.sourceforge.phpeclipse.internal.compiler.ast.ExplicitConstructorCall;
48 import net.sourceforge.phpeclipse.internal.compiler.ast.ExtendedStringLiteral;
49 import net.sourceforge.phpeclipse.internal.compiler.ast.FalseLiteral;
50 import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration;
51 import net.sourceforge.phpeclipse.internal.compiler.ast.FieldReference;
52 import net.sourceforge.phpeclipse.internal.compiler.ast.FloatLiteral;
53 import net.sourceforge.phpeclipse.internal.compiler.ast.ForStatement;
54 import net.sourceforge.phpeclipse.internal.compiler.ast.IfStatement;
55 import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference;
56 import net.sourceforge.phpeclipse.internal.compiler.ast.Initializer;
57 import net.sourceforge.phpeclipse.internal.compiler.ast.InstanceOfExpression;
58 import net.sourceforge.phpeclipse.internal.compiler.ast.IntLiteral;
59 import net.sourceforge.phpeclipse.internal.compiler.ast.LabeledStatement;
60 import net.sourceforge.phpeclipse.internal.compiler.ast.LocalDeclaration;
61 import net.sourceforge.phpeclipse.internal.compiler.ast.LocalTypeDeclaration;
62 import net.sourceforge.phpeclipse.internal.compiler.ast.LongLiteral;
63 import net.sourceforge.phpeclipse.internal.compiler.ast.MemberTypeDeclaration;
64 import net.sourceforge.phpeclipse.internal.compiler.ast.MessageSend;
65 import net.sourceforge.phpeclipse.internal.compiler.ast.MethodDeclaration;
66 import net.sourceforge.phpeclipse.internal.compiler.ast.NullLiteral;
67 import net.sourceforge.phpeclipse.internal.compiler.ast.OR_OR_Expression;
68 import net.sourceforge.phpeclipse.internal.compiler.ast.PostfixExpression;
69 import net.sourceforge.phpeclipse.internal.compiler.ast.PrefixExpression;
70 import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedAllocationExpression;
71 import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedNameReference;
72 import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedSuperReference;
73 import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedThisReference;
74 import net.sourceforge.phpeclipse.internal.compiler.ast.QualifiedTypeReference;
75 import net.sourceforge.phpeclipse.internal.compiler.ast.ReturnStatement;
76 import net.sourceforge.phpeclipse.internal.compiler.ast.SingleNameReference;
77 import net.sourceforge.phpeclipse.internal.compiler.ast.SingleTypeReference;
78 import net.sourceforge.phpeclipse.internal.compiler.ast.StringLiteral;
79 import net.sourceforge.phpeclipse.internal.compiler.ast.SuperReference;
80 import net.sourceforge.phpeclipse.internal.compiler.ast.SwitchStatement;
81 import net.sourceforge.phpeclipse.internal.compiler.ast.SynchronizedStatement;
82 import net.sourceforge.phpeclipse.internal.compiler.ast.ThisReference;
83 import net.sourceforge.phpeclipse.internal.compiler.ast.ThrowStatement;
84 import net.sourceforge.phpeclipse.internal.compiler.ast.TrueLiteral;
85 import net.sourceforge.phpeclipse.internal.compiler.ast.TryStatement;
86 import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
87 import net.sourceforge.phpeclipse.internal.compiler.ast.UnaryExpression;
88 import net.sourceforge.phpeclipse.internal.compiler.ast.WhileStatement;
92 * An adapter class for interating through the parse tree.
95 public class AbstractSyntaxTreeVisitorAdapter implements IAbstractSyntaxTreeVisitor {
97 public void acceptProblem(IProblem problem) {}
99 AllocationExpression allocationExpression,
102 public void endVisit(AND_AND_Expression and_and_Expression, BlockScope scope) {
104 public void endVisit(
105 AnonymousLocalTypeDeclaration anonymousTypeDeclaration,
108 public void endVisit(Argument argument, BlockScope scope) {
110 public void endVisit(
111 ArrayAllocationExpression arrayAllocationExpression,
114 public void endVisit(ArrayInitializer arrayInitializer, BlockScope scope) {
116 public void endVisit(
117 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
120 public void endVisit(
121 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
124 public void endVisit(ArrayReference arrayReference, BlockScope scope) {
126 public void endVisit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
128 public void endVisit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
130 public void endVisit(Assignment assignment, BlockScope scope) {
132 public void endVisit(AssertStatement assertStatement, BlockScope scope) {
134 public void endVisit(BinaryExpression binaryExpression, BlockScope scope) {
136 public void endVisit(Block block, BlockScope scope) {
138 public void endVisit(Break breakStatement, BlockScope scope) {
140 public void endVisit(Case caseStatement, BlockScope scope) {
142 public void endVisit(CastExpression castExpression, BlockScope scope) {
144 public void endVisit(CharLiteral charLiteral, BlockScope scope) {
146 public void endVisit(ClassLiteralAccess classLiteral, BlockScope scope) {
148 public void endVisit(Clinit clinit, ClassScope scope) {
150 public void endVisit(
151 CompilationUnitDeclaration compilationUnitDeclaration,
152 CompilationUnitScope scope) {
154 public void endVisit(CompoundAssignment compoundAssignment, BlockScope scope) {
156 public void endVisit(
157 ConditionalExpression conditionalExpression,
160 public void endVisit(
161 ConstructorDeclaration constructorDeclaration,
164 public void endVisit(Continue continueStatement, BlockScope scope) {
166 public void endVisit(DefaultCase defaultCaseStatement, BlockScope scope) {
168 public void endVisit(DoStatement doStatement, BlockScope scope) {
170 public void endVisit(DoubleLiteral doubleLiteral, BlockScope scope) {
172 public void endVisit(EqualExpression equalExpression, BlockScope scope) {
174 public void endVisit(
175 ExplicitConstructorCall explicitConstructor,
178 public void endVisit(
179 ExtendedStringLiteral extendedStringLiteral,
182 public void endVisit(FalseLiteral falseLiteral, BlockScope scope) {
184 public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
186 public void endVisit(FieldReference fieldReference, BlockScope scope) {
188 public void endVisit(FloatLiteral floatLiteral, BlockScope scope) {
190 public void endVisit(EmptyStatement emptyStatement, BlockScope scope) {
192 public void endVisit(ForStatement forStatement, BlockScope scope) {
194 public void endVisit(IfStatement ifStatement, BlockScope scope) {
196 public void endVisit(ImportReference importRef, CompilationUnitScope scope) {
198 public void endVisit(Initializer initializer, MethodScope scope) {
200 public void endVisit(
201 InstanceOfExpression instanceOfExpression,
204 public void endVisit(IntLiteral intLiteral, BlockScope scope) {
206 public void endVisit(LabeledStatement labeledStatement, BlockScope scope) {
208 public void endVisit(LocalDeclaration localDeclaration, BlockScope scope) {
210 public void endVisit(LongLiteral longLiteral, BlockScope scope) {
212 public void endVisit(
213 MemberTypeDeclaration memberTypeDeclaration,
216 public void endVisit(MessageSend messageSend, BlockScope scope) {
218 public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
220 public void endVisit(NullLiteral nullLiteral, BlockScope scope) {
222 public void endVisit(OR_OR_Expression or_or_Expression, BlockScope scope) {
224 public void endVisit(PostfixExpression postfixExpression, BlockScope scope) {
226 public void endVisit(PrefixExpression prefixExpression, BlockScope scope) {
228 public void endVisit(
229 QualifiedAllocationExpression qualifiedAllocationExpression,
232 public void endVisit(
233 QualifiedNameReference qualifiedNameReference,
236 public void endVisit(
237 QualifiedSuperReference qualifiedSuperReference,
240 public void endVisit(
241 QualifiedThisReference qualifiedThisReference,
244 public void endVisit(
245 QualifiedTypeReference qualifiedTypeReference,
248 public void endVisit(
249 QualifiedTypeReference qualifiedTypeReference,
252 public void endVisit(ReturnStatement returnStatement, BlockScope scope) {
254 public void endVisit(
255 SingleNameReference singleNameReference,
258 public void endVisit(
259 SingleTypeReference singleTypeReference,
262 public void endVisit(
263 SingleTypeReference singleTypeReference,
266 public void endVisit(StringLiteral stringLiteral, BlockScope scope) {
268 public void endVisit(SuperReference superReference, BlockScope scope) {
270 public void endVisit(SwitchStatement switchStatement, BlockScope scope) {
272 public void endVisit(
273 SynchronizedStatement synchronizedStatement,
276 public void endVisit(ThisReference thisReference, BlockScope scope) {
278 public void endVisit(ThrowStatement throwStatement, BlockScope scope) {
280 public void endVisit(TrueLiteral trueLiteral, BlockScope scope) {
282 public void endVisit(TryStatement tryStatement, BlockScope scope) {
284 public void endVisit(
285 TypeDeclaration typeDeclaration,
286 CompilationUnitScope scope) {
288 public void endVisit(UnaryExpression unaryExpression, BlockScope scope) {
290 public void endVisit(WhileStatement whileStatement, BlockScope scope) {
292 public boolean visit(
293 AllocationExpression allocationExpression,
297 public boolean visit(AND_AND_Expression and_and_Expression, BlockScope scope) {
300 public boolean visit(
301 AnonymousLocalTypeDeclaration anonymousTypeDeclaration,
305 public boolean visit(Argument argument, BlockScope scope) {
308 public boolean visit(
309 ArrayAllocationExpression arrayAllocationExpression,
313 public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
316 public boolean visit(
317 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
321 public boolean visit(
322 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
326 public boolean visit(ArrayReference arrayReference, BlockScope scope) {
329 public boolean visit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
332 public boolean visit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
335 public boolean visit(Assignment assignment, BlockScope scope) {
338 public boolean visit(AssertStatement assertStatement, BlockScope scope) {
341 public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
344 public boolean visit(Block block, BlockScope scope) {
347 public boolean visit(Break breakStatement, BlockScope scope) {
350 public boolean visit(Case caseStatement, BlockScope scope) {
353 public boolean visit(CastExpression castExpression, BlockScope scope) {
356 public boolean visit(CharLiteral charLiteral, BlockScope scope) {
359 public boolean visit(ClassLiteralAccess classLiteral, BlockScope scope) {
362 public boolean visit(Clinit clinit, ClassScope scope) {
365 public boolean visit(
366 CompilationUnitDeclaration compilationUnitDeclaration,
367 CompilationUnitScope scope) {
370 public boolean visit(CompoundAssignment compoundAssignment, BlockScope scope) {
373 public boolean visit(
374 ConditionalExpression conditionalExpression,
378 public boolean visit(
379 ConstructorDeclaration constructorDeclaration,
383 public boolean visit(Continue continueStatement, BlockScope scope) {
386 public boolean visit(DefaultCase defaultCaseStatement, BlockScope scope) {
389 public boolean visit(DoStatement doStatement, BlockScope scope) {
392 public boolean visit(DoubleLiteral doubleLiteral, BlockScope scope) {
395 public boolean visit(EqualExpression equalExpression, BlockScope scope) {
398 public boolean visit(EmptyStatement emptyStatement, BlockScope scope) {
401 public boolean visit(
402 ExplicitConstructorCall explicitConstructor,
406 public boolean visit(
407 ExtendedStringLiteral extendedStringLiteral,
411 public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
414 public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
417 public boolean visit(FieldReference fieldReference, BlockScope scope) {
420 public boolean visit(FloatLiteral floatLiteral, BlockScope scope) {
423 public boolean visit(ForStatement forStatement, BlockScope scope) {
426 public boolean visit(IfStatement ifStatement, BlockScope scope) {
429 public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
432 public boolean visit(Initializer initializer, MethodScope scope) {
435 public boolean visit(
436 InstanceOfExpression instanceOfExpression,
440 public boolean visit(IntLiteral intLiteral, BlockScope scope) {
443 public boolean visit(LabeledStatement labeledStatement, BlockScope scope) {
446 public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
449 public boolean visit(LongLiteral longLiteral, BlockScope scope) {
452 public boolean visit(
453 MemberTypeDeclaration memberTypeDeclaration,
457 public boolean visit(MessageSend messageSend, BlockScope scope) {
460 public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
463 public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
466 public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
469 public boolean visit(PostfixExpression postfixExpression, BlockScope scope) {
472 public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
475 public boolean visit(
476 QualifiedAllocationExpression qualifiedAllocationExpression,
480 public boolean visit(
481 QualifiedNameReference qualifiedNameReference,
485 public boolean visit(
486 QualifiedSuperReference qualifiedSuperReference,
490 public boolean visit(
491 QualifiedThisReference qualifiedThisReference,
495 public boolean visit(
496 QualifiedTypeReference qualifiedTypeReference,
500 public boolean visit(
501 QualifiedTypeReference qualifiedTypeReference,
505 public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
508 public boolean visit(
509 SingleNameReference singleNameReference,
513 public boolean visit(
514 SingleTypeReference singleTypeReference,
518 public boolean visit(
519 SingleTypeReference singleTypeReference,
523 public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
526 public boolean visit(SuperReference superReference, BlockScope scope) {
529 public boolean visit(SwitchStatement switchStatement, BlockScope scope) {
532 public boolean visit(
533 SynchronizedStatement synchronizedStatement,
537 public boolean visit(ThisReference thisReference, BlockScope scope) {
540 public boolean visit(ThrowStatement throwStatement, BlockScope scope) {
543 public boolean visit(TrueLiteral trueLiteral, BlockScope scope) {
546 public boolean visit(TryStatement tryStatement, BlockScope scope) {
549 public boolean visit(
550 TypeDeclaration typeDeclaration,
551 CompilationUnitScope scope) {
554 public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
557 public boolean visit(WhileStatement whileStatement, BlockScope scope) {
560 public boolean visit(
561 LocalTypeDeclaration localTypeDeclaration,
565 public void endVisit(
566 LocalTypeDeclaration localTypeDeclaration,