X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java index d2fac29..3602231 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java @@ -1,15 +1,23 @@ package net.sourceforge.phpdt.internal.compiler.ast; +import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage; + +import java.util.List; +import java.util.ArrayList; + /** + * An elseif statement. * @author Matthieu Casanova */ public class ElseIf extends Statement { + /** The condition. */ public Expression condition; + /** The statements. */ public Statement[] statements; - public ElseIf(Expression condition, Statement[] statements, int sourceStart, int sourceEnd) { + public ElseIf(final Expression condition, final Statement[] statements, final int sourceStart, final int sourceEnd) { super(sourceStart, sourceEnd); this.condition = condition; this.statements = statements; @@ -20,15 +28,53 @@ public class ElseIf extends Statement { * @param tab how many tabs (not used here * @return a String */ - public String toString(int tab) { + public String toString(final int tab) { final StringBuffer buff = new StringBuffer(tabString(tab)); buff.append("elseif ("); buff.append(condition.toStringExpression()); buff.append(") \n"); for (int i = 0; i < statements.length; i++) { - Statement statement = statements[i]; - buff.append(statement.toString(tab+1)).append('\n'); + final Statement statement = statements[i]; + buff.append(statement.toString(tab + 1)).append('\n'); } 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 < statements.length; i++) { + list.addAll(statements[i].getModifiedVariable()); + } + return list; + } + + /** + * get the modified variables. + * @return the variables modified + */ + public List getModifiedVariable() { + final ArrayList list = new ArrayList(); + for (int i = 0; i < statements.length; i++) { + list.addAll(statements[i].getModifiedVariable()); + } + list.addAll(condition.getModifiedVariable()); + return list; + } + + /** + * Get the variables used. + * @return the variables used + */ + public List getUsedVariable() { + final ArrayList list = new ArrayList(); + for (int i = 0; i < statements.length; i++) { + list.addAll(statements[i].getUsedVariable()); + } + list.addAll(condition.getUsedVariable()); + return list; + } }