1 package net.sourceforge.phpdt.internal.compiler.ast;
6 * It will be the mother of our own ast tree for php just like the ast tree of Eclipse.
7 * @author Matthieu Casanova
9 public abstract class AstNode {
11 /** Starting and ending position of the node in the sources. */
12 public int sourceStart, sourceEnd;
18 * Create a node giving starting and ending offset.
19 * @param sourceStart starting offset
20 * @param sourceEnd ending offset
22 protected AstNode(final int sourceStart, final int sourceEnd) {
23 this.sourceStart = sourceStart;
24 this.sourceEnd = sourceEnd;
28 * Add some tabulations.
29 * @param tab the number of tabulations
30 * @return a String containing some spaces
32 public static String tabString(final int tab) {
33 final StringBuffer s = new StringBuffer(2 * tab);
34 for (int i = tab; i > 0; i--) {
35 s.append(" "); //$NON-NLS-1$
41 * Return the object into String.
42 * It should be overriden
45 public String toString() {
46 return "****" + super.toString() + "****"; //$NON-NLS-2$ //$NON-NLS-1$
50 * Return the object into String.
51 * @param tab how many tabs (not used here
54 public abstract String toString(int tab);
57 * Get the variables from outside (parameters, globals ...)
58 * @param list the list where we will put variables
60 public abstract void getOutsideVariable(List list);
63 * get the modified variables.
64 * @param list the list where we will put variables
66 public abstract void getModifiedVariable(List list);
69 * Get the variables used.
70 * @param list the list where we will put variables
72 public abstract void getUsedVariable(List list);
75 * This method will analyze the code.
76 * by default it will do nothing
78 public void analyzeCode() {}
81 * Check if the array array contains the object o.
82 * @param array an array
84 * @return true if the array contained the object o
86 public final boolean arrayContains(final Object[] array, final Object o) {
87 for (int i = 0; i < array.length; i++) {
88 if (array[i].equals(o)) {