1 package net.sourceforge.phpdt.internal.compiler.ast;
4 * A Method declaration.
5 * @author Matthieu Casanova
7 public class MethodDeclaration extends Statement {
10 public ArgumentDeclaration[] arguments;
11 public Statement[] statements;
13 public int bodyEnd = -1;
14 public boolean isConstructor;
17 * Return method into String, with a number of tabs
18 * @param tab the number of tabs
19 * @return the String containing the method
21 public String toString(int tab) {
22 String s = tabString(tab);
23 StringBuffer buff = new StringBuffer(s);
24 buff.append(name).append("(");//$NON-NLS-1$
26 if (arguments != null) {
27 for (int i = 0; i < arguments.length; i++) {
28 buff.append(arguments[i].toString(0));
29 if (i != (arguments.length - 1)) {
30 buff.append(", "); //$NON-NLS-1$
34 buff.append(")"); //$NON-NLS-1$
36 s += toStringStatements(tab + 1);
41 * Return the statements of the method into Strings
42 * @param tab the number of tabs
43 * @return the String containing the statements
45 public String toStringStatements(int tab) {
46 StringBuffer buff = new StringBuffer(" {"); //$NON-NLS-1$
47 if (statements != null) {
48 for (int i = 0; i < statements.length; i++) {
49 buff.append("\n").append(statements[i].toString(tab)); //$NON-NLS-1$
50 if (!(statements[i] instanceof Block)) {
51 buff.append(";"); //$NON-NLS-1$
55 buff.append("\n").append(tabString(tab == 0 ? 0 : tab - 1)).append("}"); //$NON-NLS-2$ //$NON-NLS-1$
56 return buff.toString();