package net.sourceforge.phpdt.internal.compiler.ast;
+import java.util.List;
+import java.util.ArrayList;
+
/**
+ * an echo statement.
+ * echo something;
* @author Matthieu Casanova
*/
public class EchoStatement extends Statement {
/** An array of expressions in this echo statement. */
public Expression[] expressions;
- public EchoStatement (Expression[] expressions, int sourceStart) {
+ public EchoStatement (final Expression[] expressions, final int sourceStart) {
super(sourceStart, expressions[expressions.length-1].sourceEnd);
this.expressions = expressions;
}
public String toString() {
- StringBuffer buff = new StringBuffer("echo ");
+ final StringBuffer buff = new StringBuffer("echo ");//$NON-NLS-1$
for (int i = 0; i < expressions.length; i++) {
if (i != 0) {
- buff.append(", ");
+ buff.append(", ");//$NON-NLS-1$
}
- buff.append(expressions[i].toString());
+ buff.append(expressions[i].toStringExpression());
}
return buff.toString();
}
* @param tab how many tabs (not used here
* @return a String
*/
- public String toString(int tab) {
- return tabString(tab) + toString();
+ public String toString(final int tab) {
+ final String tabs = tabString(tab);
+ final String str = toString();
+ final StringBuffer buff = new StringBuffer(tabs.length()+str.length());
+ return buff.toString();
+ }
+
+ /**
+ * Get the variables from outside (parameters, globals ...)
+ * @return the variables from outside
+ */
+ public List getOutsideVariable() {
+ final ArrayList list = new ArrayList();
+ for (int i = 0; i < expressions.length; i++) {
+ list.addAll(expressions[i].getOutsideVariable());
+ }
+ return list;
+ }
+
+ /**
+ * get the modified variables.
+ * @return the variables from we change value
+ */
+ public List getModifiedVariable() {
+ final ArrayList list = new ArrayList();
+ for (int i = 0; i < expressions.length; i++) {
+ list.addAll(expressions[i].getModifiedVariable());
+ }
+ return list;
+ }
+
+ /**
+ * Get the variables used.
+ * @return the variables used
+ */
+ public List getUsedVariable() {
+ final ArrayList list = new ArrayList();
+ for (int i = 0; i < expressions.length; i++) {
+ list.addAll(expressions[i].getUsedVariable());
+ }
+ return list;
}
}