1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
7 * It will be the mother of our own ast tree for php just like the ast tree of Eclipse.
8 * @author Matthieu Casanova
10 public abstract class AstNode {
12 /** Starting and ending position of the node in the sources. */
13 public int sourceStart, sourceEnd;
16 * Create a node giving starting and ending offset
17 * @param sourceStart starting offset
18 * @param sourceEnd ending offset
20 public AstNode(final int sourceStart, final int sourceEnd) {
21 this.sourceStart = sourceStart;
22 this.sourceEnd = sourceEnd;
26 * Add some tabulations.
27 * @param tab the number of tabulations
28 * @return a String containing some spaces
30 public static String tabString(final int tab) {
31 final StringBuffer s = new StringBuffer(2 * tab);
32 for (int i = tab; i > 0; i--) {
33 s.append(" "); //$NON-NLS-1$
39 * Return the object into String.
40 * It should be overriden
43 public String toString() {
44 return "****" + super.toString() + "****"; //$NON-NLS-2$ //$NON-NLS-1$
48 * Return the object into String.
49 * @param tab how many tabs (not used here
52 public abstract String toString(int tab);
55 * Get the variables from outside (parameters, globals ...)
57 public abstract void getOutsideVariable(List list);
60 * get the modified variables.
62 public abstract void getModifiedVariable(List list);
65 * Get the variables used.
67 public abstract void getUsedVariable(List list);
70 * This method will analyze the code.
71 * by default it will do nothing
73 public void analyzeCode() {
77 * Check if the array array contains the object o
78 * @param array an array
80 * @return true if the array contained the object o
82 public boolean arrayContains(Object[] array, Object o) {
83 for (int i = 0; i < array.length; i++) {
84 if (array[i].equals(o)) {