X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java index 01e956d..24d668b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java @@ -1,5 +1,8 @@ package net.sourceforge.phpdt.internal.compiler.ast; +import java.util.List; +import java.util.ArrayList; + /** * A While statement. * @author Matthieu Casanova @@ -18,10 +21,10 @@ public class WhileStatement extends Statement { * @param sourceStart the starting offset * @param sourceEnd the ending offset */ - public WhileStatement(Expression condition, - Statement action, - int sourceStart, - int sourceEnd) { + public WhileStatement(final Expression condition, + final Statement action, + final int sourceStart, + final int sourceEnd) { super(sourceStart, sourceEnd); this.condition = condition; this.action = action; @@ -32,15 +35,54 @@ public class WhileStatement extends Statement { * @param tab how many tabs (not used here * @return a String */ - public String toString(int tab) { - final String s = tabString(tab); - final StringBuffer buff = new StringBuffer("while ("); //$NON-NLS-1$ - buff.append(condition.toStringExpression()).append(")"); //$NON-NLS-1$ - if (action == null) { - buff.append(" {} ;"); //$NON-NLS-1$ + public String toString(final int tab) { + final String s = tabString(tab); + final StringBuffer buff = new StringBuffer(s).append("while ("); //$NON-NLS-1$ + buff.append(condition.toStringExpression()).append(")"); //$NON-NLS-1$ + if (action == null) { + buff.append(" {} ;"); //$NON-NLS-1$ } else { - buff.append("\n").append(action.toString(tab + 1)); //$NON-NLS-1$ + buff.append("\n").append(action.toString(tab + 1)); //$NON-NLS-1$ + } + return buff.toString(); + } + + /** + * Get the variables from outside (parameters, globals ...) + * @return the variables from outside + */ + public List getOutsideVariable() { + final ArrayList list = new ArrayList(); + list.addAll(condition.getOutsideVariable()); // todo: check if unuseful + if (action != null) { + list.addAll(action.getOutsideVariable()); + } + return list; + } + + /** + * get the modified variables. + * @return the variables from we change value + */ + public List getModifiedVariable() { + final ArrayList list = new ArrayList(); + list.addAll(condition.getModifiedVariable()); + if (action != null) { + list.addAll(action.getModifiedVariable()); + } + return list; + } + + /** + * Get the variables used. + * @return the variables used + */ + public List getUsedVariable() { + final ArrayList list = new ArrayList(); + list.addAll(condition.getUsedVariable()); + if (action != null) { + list.addAll(action.getUsedVariable()); } - return buff.toString(); + return list; } }