improved PHP parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / internal / compiler / ast / CompilationUnitDeclaration.java
index f6852b8..53274a0 100644 (file)
@@ -12,8 +12,8 @@ package net.sourceforge.phpeclipse.internal.compiler.ast;
 import java.util.ArrayList;
 
 import net.sourceforge.phpdt.core.compiler.CharOperation;
+import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
 import net.sourceforge.phpdt.internal.compiler.CompilationResult;
-import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
 import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
 import net.sourceforge.phpdt.internal.compiler.lookup.LocalTypeBinding;
@@ -52,7 +52,6 @@ public class CompilationUnitDeclaration extends ASTNode implements ProblemSeveri
     //by definition of a compilation unit....
     sourceStart = 0;
     sourceEnd = sourceLength - 1;
-
   }
 
   /*
@@ -222,7 +221,26 @@ public class CompilationUnitDeclaration extends ASTNode implements ProblemSeveri
   public boolean hasErrors() {
     return this.ignoreFurtherInvestigation;
   }
-
+       public StringBuffer print(int indent, StringBuffer output) {
+
+               if (currentPackage != null) {
+                       printIndent(indent, output).append("package "); //$NON-NLS-1$
+                       currentPackage.print(0, output, false).append(";\n"); //$NON-NLS-1$
+               }
+               if (imports != null)
+                       for (int i = 0; i < imports.length; i++) {
+                               printIndent(indent, output).append("import "); //$NON-NLS-1$
+                               imports[i].print(0, output).append(";\n"); //$NON-NLS-1$ 
+                       }
+
+               if (types != null) {
+                       for (int i = 0; i < types.size(); i++) {
+                               ((ASTNode)types.get(i)).print(indent, output).append("\n"); //$NON-NLS-1$
+                       }
+               }
+               return output;
+       }
+       
   /*
    * Force inner local types to update their innerclass emulation
    */
@@ -298,7 +316,7 @@ public class CompilationUnitDeclaration extends ASTNode implements ProblemSeveri
     return s;
   }
 
-  public void traverse(IAbstractSyntaxTreeVisitor visitor, CompilationUnitScope scope) {
+  public void traverse(ASTVisitor visitor, CompilationUnitScope scope) {
 
     if (ignoreFurtherInvestigation)
       return;