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;
15 * Create a node giving starting and ending offset.
16 * @param sourceStart starting offset
17 * @param sourceEnd ending offset
19 protected AstNode(final int sourceStart, final int sourceEnd) {
20 this.sourceStart = sourceStart;
21 this.sourceEnd = sourceEnd;
25 * Add some tabulations.
26 * @param tab the number of tabulations
27 * @return a String containing some spaces
29 public static String tabString(final int tab) {
30 final StringBuffer s = new StringBuffer(2 * tab);
31 for (int i = tab; i > 0; i--) {
32 s.append(" "); //$NON-NLS-1$
38 * Return the object into String.
39 * It should be overriden
42 public String toString() {
43 return "****" + super.toString() + "****"; //$NON-NLS-2$ //$NON-NLS-1$
47 * Return the object into String.
48 * @param tab how many tabs (not used here
51 public abstract String toString(int tab);
54 * Get the variables from outside (parameters, globals ...)
55 * @param list the list where we will put variables
57 public abstract void getOutsideVariable(List list);
60 * get the modified variables.
61 * @param list the list where we will put variables
63 public abstract void getModifiedVariable(List list);
66 * Get the variables used.
67 * @param list the list where we will put variables
69 public abstract void getUsedVariable(List list);
72 * This method will analyze the code.
73 * by default it will do nothing
75 public void analyzeCode() {}
78 * Check if the array array contains the object o.
79 * @param array an array
81 * @return true if the array contained the object o
83 public final boolean arrayContains(final Object[] array, final Object o) {
84 for (int i = 0; i < array.length; i++) {
85 if (array[i].equals(o)) {