X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java index b3ef5d1..d2371be 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java @@ -1,7 +1,10 @@ package net.sourceforge.phpdt.internal.compiler.ast; +import java.util.List; +import java.util.ArrayList; + /** - * A Block is + * A Block. * { * statements * }. @@ -18,30 +21,72 @@ public class Block extends Statement { * @param sourceStart starting offset * @param sourceEnd ending offset */ - public Block(Statement[] statements,int sourceStart, int sourceEnd) { + public Block(final Statement[] statements, + final int sourceStart, + final int sourceEnd) { super(sourceStart, sourceEnd); this.statements = statements; } + /** + * tell if the block is empty. + * @return the block is empty if there are no statements in it + */ public boolean isEmptyBlock() { return statements == null; } /** * Return the block as String. - * @param tab how many tabs + * @param tab how many tabs * @return the string representation of the block */ - public String toString(int tab) { + public String toString(final int tab) { final String s = AstNode.tabString(tab); final StringBuffer buff = new StringBuffer(s); buff.append("{\n"); //$NON-NLS-1$ if (this.statements != null) { for (int i = 0; i < statements.length; i++) { - buff.append(statements[i].toString(tab+1)).append(";\n");//$NON-NLS-1$ + buff.append(statements[i].toString(tab + 1)).append(";\n");//$NON-NLS-1$ } } buff.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 we change value + */ + 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 used + */ + public List getUsedVariable() { + final ArrayList list = new ArrayList(); + for (int i = 0; i < statements.length; i++) { + list.addAll(statements[i].getUsedVariable()); + } + return list; + } }