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.ast.AND_AND_Expression;
 
  15 import net.sourceforge.phpdt.internal.compiler.ast.AllocationExpression;
 
  16 import net.sourceforge.phpdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
 
  17 import net.sourceforge.phpdt.internal.compiler.ast.Argument;
 
  18 import net.sourceforge.phpdt.internal.compiler.ast.ArrayAllocationExpression;
 
  19 import net.sourceforge.phpdt.internal.compiler.ast.ArrayInitializer;
 
  20 import net.sourceforge.phpdt.internal.compiler.ast.ArrayQualifiedTypeReference;
 
  21 import net.sourceforge.phpdt.internal.compiler.ast.ArrayReference;
 
  22 import net.sourceforge.phpdt.internal.compiler.ast.ArrayTypeReference;
 
  23 import net.sourceforge.phpdt.internal.compiler.ast.AssertStatement;
 
  24 import net.sourceforge.phpdt.internal.compiler.ast.Assignment;
 
  25 import net.sourceforge.phpdt.internal.compiler.ast.BinaryExpression;
 
  26 import net.sourceforge.phpdt.internal.compiler.ast.Block;
 
  27 import net.sourceforge.phpdt.internal.compiler.ast.BreakStatement;
 
  28 import net.sourceforge.phpdt.internal.compiler.ast.CaseStatement;
 
  29 import net.sourceforge.phpdt.internal.compiler.ast.CastExpression;
 
  30 import net.sourceforge.phpdt.internal.compiler.ast.Clinit;
 
  31 import net.sourceforge.phpdt.internal.compiler.ast.CompilationUnitDeclaration;
 
  32 import net.sourceforge.phpdt.internal.compiler.ast.CompoundAssignment;
 
  33 import net.sourceforge.phpdt.internal.compiler.ast.ConditionalExpression;
 
  34 import net.sourceforge.phpdt.internal.compiler.ast.ConstructorDeclaration;
 
  35 import net.sourceforge.phpdt.internal.compiler.ast.ContinueStatement;
 
  36 import net.sourceforge.phpdt.internal.compiler.ast.DefaultCase;
 
  37 import net.sourceforge.phpdt.internal.compiler.ast.DoStatement;
 
  38 import net.sourceforge.phpdt.internal.compiler.ast.DoubleLiteral;
 
  39 import net.sourceforge.phpdt.internal.compiler.ast.EmptyStatement;
 
  40 import net.sourceforge.phpdt.internal.compiler.ast.EqualExpression;
 
  41 import net.sourceforge.phpdt.internal.compiler.ast.ExplicitConstructorCall;
 
  42 import net.sourceforge.phpdt.internal.compiler.ast.ExtendedStringLiteral;
 
  43 import net.sourceforge.phpdt.internal.compiler.ast.FalseLiteral;
 
  44 import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration;
 
  45 import net.sourceforge.phpdt.internal.compiler.ast.FieldReference;
 
  46 import net.sourceforge.phpdt.internal.compiler.ast.FloatLiteral;
 
  47 import net.sourceforge.phpdt.internal.compiler.ast.ForStatement;
 
  48 import net.sourceforge.phpdt.internal.compiler.ast.IfStatement;
 
  49 import net.sourceforge.phpdt.internal.compiler.ast.ImportReference;
 
  50 import net.sourceforge.phpdt.internal.compiler.ast.Initializer;
 
  51 import net.sourceforge.phpdt.internal.compiler.ast.InstanceOfExpression;
 
  52 import net.sourceforge.phpdt.internal.compiler.ast.IntLiteral;
 
  53 import net.sourceforge.phpdt.internal.compiler.ast.LabeledStatement;
 
  54 import net.sourceforge.phpdt.internal.compiler.ast.LocalDeclaration;
 
  55 import net.sourceforge.phpdt.internal.compiler.ast.LocalTypeDeclaration;
 
  56 import net.sourceforge.phpdt.internal.compiler.ast.LongLiteral;
 
  57 import net.sourceforge.phpdt.internal.compiler.ast.MemberTypeDeclaration;
 
  58 import net.sourceforge.phpdt.internal.compiler.ast.MessageSend;
 
  59 import net.sourceforge.phpdt.internal.compiler.ast.MethodDeclaration;
 
  60 import net.sourceforge.phpdt.internal.compiler.ast.NullLiteral;
 
  61 import net.sourceforge.phpdt.internal.compiler.ast.OR_OR_Expression;
 
  62 import net.sourceforge.phpdt.internal.compiler.ast.PostfixExpression;
 
  63 import net.sourceforge.phpdt.internal.compiler.ast.PrefixExpression;
 
  64 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedAllocationExpression;
 
  65 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedNameReference;
 
  66 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedSuperReference;
 
  67 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedThisReference;
 
  68 import net.sourceforge.phpdt.internal.compiler.ast.QualifiedTypeReference;
 
  69 import net.sourceforge.phpdt.internal.compiler.ast.ReturnStatement;
 
  70 import net.sourceforge.phpdt.internal.compiler.ast.SingleNameReference;
 
  71 import net.sourceforge.phpdt.internal.compiler.ast.SingleTypeReference;
 
  72 import net.sourceforge.phpdt.internal.compiler.ast.StringLiteral;
 
  73 import net.sourceforge.phpdt.internal.compiler.ast.SuperReference;
 
  74 import net.sourceforge.phpdt.internal.compiler.ast.SwitchStatement;
 
  75 import net.sourceforge.phpdt.internal.compiler.ast.ThisReference;
 
  76 import net.sourceforge.phpdt.internal.compiler.ast.ThrowStatement;
 
  77 import net.sourceforge.phpdt.internal.compiler.ast.TrueLiteral;
 
  78 import net.sourceforge.phpdt.internal.compiler.ast.TryStatement;
 
  79 import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration;
 
  80 import net.sourceforge.phpdt.internal.compiler.ast.UnaryExpression;
 
  81 import net.sourceforge.phpdt.internal.compiler.ast.WhileStatement;
 
  82 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 
  83 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
 
  84 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
 
  85 import net.sourceforge.phpdt.internal.compiler.lookup.MethodScope;
 
  89  * An adapter class for interating through the parse tree.
 
  92 public class AbstractSyntaxTreeVisitorAdapter implements IAbstractSyntaxTreeVisitor {
 
  94         public void acceptProblem(IProblem problem) {}
 
  96                 AllocationExpression allocationExpression,
 
  99         public void endVisit(AND_AND_Expression and_and_Expression, BlockScope scope) {
 
 101         public void endVisit(
 
 102                 AnonymousLocalTypeDeclaration anonymousTypeDeclaration,
 
 105         public void endVisit(Argument argument, BlockScope scope) {
 
 107         public void endVisit(
 
 108                 ArrayAllocationExpression arrayAllocationExpression,
 
 111         public void endVisit(ArrayInitializer arrayInitializer, BlockScope scope) {
 
 113         public void endVisit(
 
 114                 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
 
 117         public void endVisit(
 
 118                 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
 
 121         public void endVisit(ArrayReference arrayReference, BlockScope scope) {
 
 123         public void endVisit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
 
 125         public void endVisit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
 
 127         public void endVisit(Assignment assignment, BlockScope scope) {
 
 129         public void endVisit(AssertStatement assertStatement, BlockScope scope) {
 
 131         public void endVisit(BinaryExpression binaryExpression, BlockScope scope) {
 
 133         public void endVisit(Block block, BlockScope scope) {
 
 135         public void endVisit(BreakStatement breakStatement, BlockScope scope) {
 
 137         public void endVisit(CaseStatement caseStatement, BlockScope scope) {
 
 139         public void endVisit(CastExpression castExpression, BlockScope scope) {
 
 141         public void endVisit(Clinit clinit, ClassScope scope) {
 
 143         public void endVisit(
 
 144                 CompilationUnitDeclaration compilationUnitDeclaration,
 
 145                 CompilationUnitScope scope) {
 
 147         public void endVisit(CompoundAssignment compoundAssignment, BlockScope scope) {
 
 149         public void endVisit(
 
 150                 ConditionalExpression conditionalExpression,
 
 153         public void endVisit(
 
 154                 ConstructorDeclaration constructorDeclaration,
 
 157         public void endVisit(ContinueStatement continueStatement, BlockScope scope) {
 
 159         public void endVisit(DefaultCase defaultCaseStatement, BlockScope scope) {
 
 161         public void endVisit(DoStatement doStatement, BlockScope scope) {
 
 163         public void endVisit(DoubleLiteral doubleLiteral, BlockScope scope) {
 
 165         public void endVisit(EqualExpression equalExpression, BlockScope scope) {
 
 167         public void endVisit(
 
 168                 ExplicitConstructorCall explicitConstructor,
 
 171         public void endVisit(
 
 172                 ExtendedStringLiteral extendedStringLiteral,
 
 175         public void endVisit(FalseLiteral falseLiteral, BlockScope scope) {
 
 177         public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
 
 179         public void endVisit(FieldReference fieldReference, BlockScope scope) {
 
 181         public void endVisit(FloatLiteral floatLiteral, BlockScope scope) {
 
 183         public void endVisit(EmptyStatement emptyStatement, BlockScope scope) {
 
 185         public void endVisit(ForStatement forStatement, BlockScope scope) {
 
 187         public void endVisit(IfStatement ifStatement, BlockScope scope) {
 
 189         public void endVisit(ImportReference importRef, CompilationUnitScope scope) {
 
 191         public void endVisit(Initializer initializer, MethodScope scope) {
 
 193         public void endVisit(
 
 194                 InstanceOfExpression instanceOfExpression,
 
 197         public void endVisit(IntLiteral intLiteral, BlockScope scope) {
 
 199         public void endVisit(LabeledStatement labeledStatement, BlockScope scope) {
 
 201         public void endVisit(LocalDeclaration localDeclaration, BlockScope scope) {
 
 203         public void endVisit(LongLiteral longLiteral, BlockScope scope) {
 
 205         public void endVisit(
 
 206                 MemberTypeDeclaration memberTypeDeclaration,
 
 209         public void endVisit(MessageSend messageSend, BlockScope scope) {
 
 211         public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
 
 213         public void endVisit(NullLiteral nullLiteral, BlockScope scope) {
 
 215         public void endVisit(OR_OR_Expression or_or_Expression, BlockScope scope) {
 
 217         public void endVisit(PostfixExpression postfixExpression, BlockScope scope) {
 
 219         public void endVisit(PrefixExpression prefixExpression, BlockScope scope) {
 
 221         public void endVisit(
 
 222                 QualifiedAllocationExpression qualifiedAllocationExpression,
 
 225         public void endVisit(
 
 226                 QualifiedNameReference qualifiedNameReference,
 
 229         public void endVisit(
 
 230                 QualifiedSuperReference qualifiedSuperReference,
 
 233         public void endVisit(
 
 234                 QualifiedThisReference qualifiedThisReference,
 
 237         public void endVisit(
 
 238                 QualifiedTypeReference qualifiedTypeReference,
 
 241         public void endVisit(
 
 242                 QualifiedTypeReference qualifiedTypeReference,
 
 245         public void endVisit(ReturnStatement returnStatement, BlockScope scope) {
 
 247         public void endVisit(
 
 248                 SingleNameReference singleNameReference,
 
 251         public void endVisit(
 
 252                 SingleTypeReference singleTypeReference,
 
 255         public void endVisit(
 
 256                 SingleTypeReference singleTypeReference,
 
 259         public void endVisit(StringLiteral stringLiteral, BlockScope scope) {
 
 261         public void endVisit(SuperReference superReference, BlockScope scope) {
 
 263         public void endVisit(SwitchStatement switchStatement, BlockScope scope) {
 
 266         public void endVisit(ThisReference thisReference, BlockScope scope) {
 
 268         public void endVisit(ThrowStatement throwStatement, BlockScope scope) {
 
 270         public void endVisit(TrueLiteral trueLiteral, BlockScope scope) {
 
 272         public void endVisit(TryStatement tryStatement, BlockScope scope) {
 
 274         public void endVisit(
 
 275                 TypeDeclaration typeDeclaration,
 
 276                 CompilationUnitScope scope) {
 
 278         public void endVisit(UnaryExpression unaryExpression, BlockScope scope) {
 
 280         public void endVisit(WhileStatement whileStatement, BlockScope scope) {
 
 282         public boolean visit(
 
 283                 AllocationExpression allocationExpression,
 
 287         public boolean visit(AND_AND_Expression and_and_Expression, BlockScope scope) {
 
 290         public boolean visit(
 
 291                 AnonymousLocalTypeDeclaration anonymousTypeDeclaration,
 
 295         public boolean visit(Argument argument, BlockScope scope) {
 
 298         public boolean visit(
 
 299                 ArrayAllocationExpression arrayAllocationExpression,
 
 303         public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
 
 306         public boolean visit(
 
 307                 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
 
 311         public boolean visit(
 
 312                 ArrayQualifiedTypeReference arrayQualifiedTypeReference,
 
 316         public boolean visit(ArrayReference arrayReference, BlockScope scope) {
 
 319         public boolean visit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
 
 322         public boolean visit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
 
 325         public boolean visit(Assignment assignment, BlockScope scope) {
 
 328         public boolean visit(AssertStatement assertStatement, BlockScope scope) {
 
 331         public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
 
 334         public boolean visit(Block block, BlockScope scope) {
 
 337         public boolean visit(BreakStatement breakStatement, BlockScope scope) {
 
 340         public boolean visit(CaseStatement caseStatement, BlockScope scope) {
 
 343         public boolean visit(CastExpression castExpression, BlockScope scope) {
 
 347         public boolean visit(Clinit clinit, ClassScope scope) {
 
 350         public boolean visit(
 
 351                 CompilationUnitDeclaration compilationUnitDeclaration,
 
 352                 CompilationUnitScope scope) {
 
 355         public boolean visit(CompoundAssignment compoundAssignment, BlockScope scope) {
 
 358         public boolean visit(
 
 359                 ConditionalExpression conditionalExpression,
 
 363         public boolean visit(
 
 364                 ConstructorDeclaration constructorDeclaration,
 
 368         public boolean visit(ContinueStatement continueStatement, BlockScope scope) {
 
 371         public boolean visit(DefaultCase defaultCaseStatement, BlockScope scope) {
 
 374         public boolean visit(DoStatement doStatement, BlockScope scope) {
 
 377         public boolean visit(DoubleLiteral doubleLiteral, BlockScope scope) {
 
 380         public boolean visit(EqualExpression equalExpression, BlockScope scope) {
 
 383         public boolean visit(EmptyStatement emptyStatement, BlockScope scope) {
 
 386         public boolean visit(
 
 387                 ExplicitConstructorCall explicitConstructor,
 
 391         public boolean visit(
 
 392                 ExtendedStringLiteral extendedStringLiteral,
 
 396         public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
 
 399         public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
 
 402         public boolean visit(FieldReference fieldReference, BlockScope scope) {
 
 405         public boolean visit(FloatLiteral floatLiteral, BlockScope scope) {
 
 408         public boolean visit(ForStatement forStatement, BlockScope scope) {
 
 411         public boolean visit(IfStatement ifStatement, BlockScope scope) {
 
 414         public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
 
 417         public boolean visit(Initializer initializer, MethodScope scope) {
 
 420         public boolean visit(
 
 421                 InstanceOfExpression instanceOfExpression,
 
 425         public boolean visit(IntLiteral intLiteral, BlockScope scope) {
 
 428         public boolean visit(LabeledStatement labeledStatement, BlockScope scope) {
 
 431         public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
 
 434         public boolean visit(LongLiteral longLiteral, BlockScope scope) {
 
 437         public boolean visit(
 
 438                 MemberTypeDeclaration memberTypeDeclaration,
 
 442         public boolean visit(MessageSend messageSend, BlockScope scope) {
 
 445         public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
 
 448         public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
 
 451         public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
 
 454         public boolean visit(PostfixExpression postfixExpression, BlockScope scope) {
 
 457         public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
 
 460         public boolean visit(
 
 461                 QualifiedAllocationExpression qualifiedAllocationExpression,
 
 465         public boolean visit(
 
 466                 QualifiedNameReference qualifiedNameReference,
 
 470         public boolean visit(
 
 471                 QualifiedSuperReference qualifiedSuperReference,
 
 475         public boolean visit(
 
 476                 QualifiedThisReference qualifiedThisReference,
 
 480         public boolean visit(
 
 481                 QualifiedTypeReference qualifiedTypeReference,
 
 485         public boolean visit(
 
 486                 QualifiedTypeReference qualifiedTypeReference,
 
 490         public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
 
 493         public boolean visit(
 
 494                 SingleNameReference singleNameReference,
 
 498         public boolean visit(
 
 499                 SingleTypeReference singleTypeReference,
 
 503         public boolean visit(
 
 504                 SingleTypeReference singleTypeReference,
 
 508         public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
 
 511         public boolean visit(SuperReference superReference, BlockScope scope) {
 
 514         public boolean visit(SwitchStatement switchStatement, BlockScope scope) {
 
 518         public boolean visit(ThisReference thisReference, BlockScope scope) {
 
 521         public boolean visit(ThrowStatement throwStatement, BlockScope scope) {
 
 524         public boolean visit(TrueLiteral trueLiteral, BlockScope scope) {
 
 527         public boolean visit(TryStatement tryStatement, BlockScope scope) {
 
 530         public boolean visit(
 
 531                 TypeDeclaration typeDeclaration,
 
 532                 CompilationUnitScope scope) {
 
 535         public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
 
 538         public boolean visit(WhileStatement whileStatement, BlockScope scope) {
 
 541         public boolean visit(
 
 542                 LocalTypeDeclaration localTypeDeclaration,
 
 546         public void endVisit(
 
 547                 LocalTypeDeclaration localTypeDeclaration,