1 package net.sourceforge.phpdt.internal.compiler.ast;
10 * @author Matthieu Casanova
12 public class Block extends Statement {
14 /** An array of statements inside the block. */
15 public 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 (this.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 public void getOutsideVariable(final List list) {
60 for (int i = 0; i < statements.length; i++) {
61 statements[i].getOutsideVariable(list);
66 * get the modified variables.
68 public void getModifiedVariable(final List list) {
69 for (int i = 0; i < statements.length; i++) {
70 statements[i].getModifiedVariable(list);
75 * Get the variables used.
77 public void getUsedVariable(final List list) {
78 for (int i = 0; i < statements.length; i++) {
79 statements[i].getUsedVariable(list);