X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java index 5ac7c04..769dc4b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java @@ -1,19 +1,34 @@ package net.sourceforge.phpdt.internal.compiler.ast; +import java.util.List; +import java.util.ArrayList; + /** + * A list expression. + * it could be list($v1,$v2), list(,$v2) ... * @author Matthieu Casanova */ public class ListExpression extends Expression { - public String[] vars; + public Expression[] vars; public Expression expression; - public ListExpression(String[] vars, Expression expression, int sourceStart, int sourceEnd) { + public ListExpression(final Expression[] vars, + final Expression expression, + final int sourceStart, + final int sourceEnd) { super(sourceStart, sourceEnd); this.vars = vars; this.expression = expression; } + public ListExpression(final Expression[] vars, + final int sourceStart, + final int sourceEnd) { + super(sourceStart, sourceEnd); + this.vars = vars; + } + /** * Return the expression as String. * @return the expression @@ -21,12 +36,11 @@ public class ListExpression extends Expression { public String toStringExpression() { final StringBuffer buff = new StringBuffer("list("); for (int i = 0; i < vars.length; i++) { - String var = vars[i]; if (i != 0) { buff.append(", "); } - if (var != null) { - buff.append(vars); + if (vars[i] != null) { + buff.append(vars[i].toStringExpression()); } } if (expression != null) { @@ -35,4 +49,38 @@ public class ListExpression extends Expression { } return buff.toString(); } + + /** + * Get the variables from outside (parameters, globals ...) + * @return the variables from outside + */ + public List getOutsideVariable() { + return new ArrayList(); + } + + /** + * get the modified variables. + * @return the variables from we change value + */ + public List getModifiedVariable() { + final ArrayList list = new ArrayList(); + for (int i = 0; i < vars.length; i++) { + list.addAll(vars[i].getModifiedVariable()); + } + if (expression != null) { + list.addAll(expression.getModifiedVariable()); + } + return list; + } + + /** + * Get the variables used. + * @return the variables used + */ + public List getUsedVariable() { + if (expression == null) { + return new ArrayList(1); + } + return expression.getUsedVariable(); + } }