1 package net.sourceforge.phpdt.internal.compiler.ast;
10 * @author Matthieu Casanova
12 public final class Block extends Statement {
14 /** An array of statements inside the block. */
15 public final Statement[] statements;
19 * @param statements the statements
20 * @param sourceStart starting offset
21 * @param sourceEnd ending offset
23 public Block(final Statement[] statements,
24 final int sourceStart,
25 final int sourceEnd) {
26 super(sourceStart, sourceEnd);
27 this.statements = statements;
31 * tell if the block is empty.
32 * @return the block is empty if there are no statements in it
34 public boolean isEmptyBlock() {
35 return statements == null;
39 * Return the block as String.
40 * @param tab how many tabs
41 * @return the string representation of the block
43 public String toString(final int tab) {
44 final String s = AstNode.tabString(tab);
45 final StringBuffer buff = new StringBuffer(s);
46 buff.append("{\n"); //$NON-NLS-1$
47 if (statements != null) {
48 for (int i = 0; i < statements.length; i++) {
49 buff.append(statements[i].toString(tab + 1)).append(";\n");//$NON-NLS-1$
52 buff.append("}\n"); //$NON-NLS-1$
53 return buff.toString();
57 * Get the variables from outside (parameters, globals ...)
59 * @param list the list where we will put variables
61 public void getOutsideVariable(final List list) {
62 for (int i = 0; i < statements.length; i++) {
63 statements[i].getOutsideVariable(list);
68 * get the modified variables.
70 * @param list the list where we will put variables
72 public void getModifiedVariable(final List list) {
73 for (int i = 0; i < statements.length; i++) {
74 statements[i].getModifiedVariable(list);
79 * Get the variables used.
81 * @param list the list where we will put variables
83 public void getUsedVariable(final List list) {
84 for (int i = 0; i < statements.length; i++) {
85 statements[i].getUsedVariable(list);