Some minor changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / AstNode.java
index 9eabb41..4d3aec2 100644 (file)
@@ -1,5 +1,7 @@
 package net.sourceforge.phpdt.internal.compiler.ast;
 
+import java.util.List;
+
 /**
  * It will be the mother of our own ast tree for php just like the ast tree of Eclipse.
  * @author Matthieu Casanova
@@ -10,11 +12,11 @@ public abstract class AstNode {
   public int sourceStart, sourceEnd;
 
   /**
-   * Create a node giving starting and ending offset
+   * Create a node giving starting and ending offset.
    * @param sourceStart starting offset
    * @param sourceEnd ending offset
    */
-  public AstNode(int sourceStart, int sourceEnd) {
+  protected AstNode(final int sourceStart, final int sourceEnd) {
     this.sourceStart = sourceStart;
     this.sourceEnd = sourceEnd;
   }
@@ -24,10 +26,11 @@ public abstract class AstNode {
    * @param tab the number of tabulations
    * @return a String containing some spaces
    */
-  public static String tabString(int tab) {
-    StringBuffer s = new StringBuffer();
-    for (int i = tab; i > 0; i--)
+  public static String tabString(final int tab) {
+    final StringBuffer s = new StringBuffer(2 * tab);
+    for (int i = tab; i > 0; i--) {
       s.append("  "); //$NON-NLS-1$
+    }
     return s.toString();
   }
 
@@ -46,4 +49,43 @@ public abstract class AstNode {
    * @return a String
    */
   public abstract String toString(int tab);
+
+  /**
+   * Get the variables from outside (parameters, globals ...)
+   * @param list the list where we will put variables
+   */
+  public abstract void getOutsideVariable(List list);
+
+  /**
+   * get the modified variables.
+   * @param list the list where we will put variables
+   */
+  public abstract void getModifiedVariable(List list);
+
+  /**
+   * Get the variables used.
+   * @param list the list where we will put variables
+   */
+  public abstract void getUsedVariable(List list);
+
+  /**
+   * This method will analyze the code.
+   * by default it will do nothing
+   */
+  public void analyzeCode() {}
+
+  /**
+   * Check if the array array contains the object o.
+   * @param array an array
+   * @param o an obejct
+   * @return true if the array contained the object o
+   */
+  public final boolean arrayContains(final Object[] array, final Object o) {
+    for (int i = 0; i < array.length; i++) {
+      if (array[i].equals(o)) {
+        return true;
+      }
+    }
+    return false;
+  }
 }