1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
11 * @author Matthieu Casanova
13 public class Block extends Statement {
15 /** An array of statements inside the block. */
16 public Statement[] statements;
20 * @param statements the statements
21 * @param sourceStart starting offset
22 * @param sourceEnd ending offset
24 public Block(final Statement[] statements,
25 final int sourceStart,
26 final int sourceEnd) {
27 super(sourceStart, sourceEnd);
28 this.statements = statements;
32 * tell if the block is empty.
33 * @return the block is empty if there are no statements in it
35 public boolean isEmptyBlock() {
36 return statements == null;
40 * Return the block as String.
41 * @param tab how many tabs
42 * @return the string representation of the block
44 public String toString(final int tab) {
45 final String s = AstNode.tabString(tab);
46 final StringBuffer buff = new StringBuffer(s);
47 buff.append("{\n"); //$NON-NLS-1$
48 if (this.statements != null) {
49 for (int i = 0; i < statements.length; i++) {
50 buff.append(statements[i].toString(tab + 1)).append(";\n");//$NON-NLS-1$
53 buff.append("}\n"); //$NON-NLS-1$
54 return buff.toString();
58 * Get the variables from outside (parameters, globals ...)
59 * @return the variables from outside
61 public List getOutsideVariable() {
62 final ArrayList list = new ArrayList();
63 for (int i = 0; i < statements.length; i++) {
64 list.addAll(statements[i].getOutsideVariable());
70 * get the modified variables.
71 * @return the variables from we change value
73 public List getModifiedVariable() {
74 final ArrayList list = new ArrayList();
75 for (int i = 0; i < statements.length; i++) {
76 list.addAll(statements[i].getModifiedVariable());
82 * Get the variables used.
83 * @return the variables used
85 public List getUsedVariable() {
86 final ArrayList list = new ArrayList();
87 for (int i = 0; i < statements.length; i++) {
88 list.addAll(statements[i].getUsedVariable());