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 ...)
56 * @return the variables from outside
58 public abstract List getOutsideVariable();
61 * get the modified variables.
62 * @return the variables modified
64 public abstract List getModifiedVariable();
67 * Get the variables used.
68 * @return the variables used
70 public abstract List getUsedVariable();
73 * This method will analyze the code.
74 * by default it will do nothing
76 public void analyzeCode() {
80 * Check if the array array contains the object o
81 * @param array an array
83 * @return true if the array contained the object o
85 public boolean arrayContains(Object[] array, Object o) {
86 for (int i = 0; i < array.length; i++) {
87 if (array[i].equals(o)) {