X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java index d0e1ea6..302d650 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java @@ -1,18 +1,40 @@ package net.sourceforge.phpdt.internal.compiler.ast; +import java.util.ArrayList; +import java.util.List; + /** + * an else statement. + * it's else * @author Matthieu Casanova */ public class Else extends Statement { + /** the statements. */ public Statement[] statements; - public Else(Statement[] statements, int sourceStart, int sourceEnd) { + /** + * An else statement bad version ( : endif). + * @param statements the statements + * @param sourceStart the starting offset + * @param sourceEnd the ending offset + */ + public Else(final Statement[] statements, + final int sourceStart, + final int sourceEnd) { super(sourceStart, sourceEnd); this.statements = statements; } - public Else(Statement statement, int sourceStart, int sourceEnd) { + /** + * An else statement good version + * @param statement the statement (it could be a block) + * @param sourceStart the starting offset + * @param sourceEnd the ending offset + */ + public Else(final Statement statement, + final int sourceStart, + final int sourceEnd) { super(sourceStart, sourceEnd); this.statements = new Statement[1]; this.statements[0] = statement; @@ -23,13 +45,50 @@ public class Else 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("else \n"); + buff.append("else \n");//$NON-NLS-1$ + Statement statement; for (int i = 0; i < statements.length; i++) { - Statement statement = statements[i]; - buff.append(statement.toString(tab + 1)).append('\n'); + statement = statements[i]; + buff.append(statement.toString(tab + 1)).append("\n");//$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(); + for (int i = 0; i < statements.length; i++) { + list.addAll(statements[i].getOutsideVariable()); + } + return list; + } + + /** + * get the modified variables. + * @return the variables from outside + */ + public List getModifiedVariable() { + final ArrayList list = new ArrayList(); + for (int i = 0; i < statements.length; i++) { + list.addAll(statements[i].getModifiedVariable()); + } + return list; + } + + /** + * Get the variables used. + * @return the variables from outside + */ + public List getUsedVariable() { + final ArrayList list = new ArrayList(); + for (int i = 0; i < statements.length; i++) { + list.addAll(statements[i].getUsedVariable()); + } + return list; + } }