package ca.uwaterloo.joos.ast.decl;

import java.util.List;

import ca.uwaterloo.joos.ast.ASTNode;
import ca.uwaterloo.joos.ast.body.Block;
import ca.uwaterloo.joos.ast.descriptor.ChildDescriptor;
import ca.uwaterloo.joos.parser.ParseTree.Node;
import ca.uwaterloo.joos.parser.ParseTree.TreeNode;


public class MethodDeclaration extends BodyDeclaration {
	
//	protected static final ChildListDescriptor PARAMETERS = new ChildDescriptor(Parameters.class);
	protected static final ChildDescriptor BODY = new ChildDescriptor(Block.class);

	public MethodDeclaration(Node node, ASTNode parent) throws Exception {
		super(node, parent);
	}
	
//	public List<Parameters> getParameters() throws ChildTypeUnmatchException {
//		return (List<Parameters>) this.getChildByDescriptor(MethodDeclaration.PARAMETERS);
//	}
	
	public Block getBody() throws ChildTypeUnmatchException {
		return (Block) this.getChildByDescriptor(MethodDeclaration.BODY);
	}

	/* (non-Javadoc)
	 * @see ca.uwaterloo.joos.parser.ParseTreeTraverse.Traverser#processTreeNode(ca.uwaterloo.joos.parser.ParseTree.TreeNode)
	 */
	@Override
	public List<Node> processTreeNode(TreeNode treeNode) throws Exception {
        if(treeNode.productionRule.getLefthand().equals("param")) {
//              returnType = new Type();
        }
        else if(treeNode.productionRule.getLefthand().equals("block")) {
                Block body = new Block(treeNode, this);
                addChild(BODY, body);
        }
        else {
             return super.processTreeNode(treeNode);
        }
        return null;
	}
}

@@ -30,16 +30,44 @@
 .decl;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -218,16 +218,77 @@
 riptor;%0A
+import ca.uwaterloo.joos.ast.descriptor.ChildListDescriptor;%0A
 import c
@@ -380,17 +380,16 @@
 eNode;%0A%0A
-%0A
 public c
@@ -437,20 +437,17 @@
 ation %7B%0A
-%09%0A//
+%0A
 %09protect
@@ -496,32 +496,36 @@
 TERS = new Child
+List
 Descriptor(Param
@@ -528,17 +528,27 @@
 arameter
-s
+Declaration
 .class);
@@ -732,12 +732,41 @@
 %0A%09%7D%0A
-%09%0A//
+%0A%09@SuppressWarnings(%22unchecked%22)%0A
 %09pub
@@ -783,17 +783,27 @@
 arameter
-s
+Declaration
 %3E getPar
@@ -847,18 +847,16 @@
 ption %7B%0A
-//
 %09%09return
@@ -871,17 +871,27 @@
 arameter
-s
+Declaration
 %3E) this.
@@ -946,14 +946,11 @@
 S);%0A
-//
 %09%7D%0A
-%09
 %0A%09pu
@@ -1080,16 +1080,20 @@
 %0A%09%7D%0A%0A%09/*
+%0A%09 *
  (non-Ja
@@ -1107,12 +1107,21 @@
 %09 * 
-@see
+%0A%09 * @see%0A%09 *
  ca.
@@ -1186,16 +1186,21 @@
 reeNode(
+%0A%09 * 
 ca.uwate
@@ -1329,18 +1329,13 @@
 n %7B%0A
-        
+%09%09
 if
+ 
 (tre
@@ -1392,74 +1392,343 @@
 ) %7B%0A
-//              returnType = new Type();%0A        %7D%0A       
+%09%09%09List%3CParameterDeclaration%3E parameters = this.getParameters();%0A%09%09%09if (parameters == null) %7B%0A%09%09%09%09parameters = new ArrayList%3CParameterDeclaration%3E();%0A%09%09%09%09this.addChild(MethodDeclaration.PARAMETERS, parameters);%0A%09%09%09%7D%0A%09%09%09ParameterDeclaration parameter = new ParameterDeclaration(treeNode, this);%0A%09%09%09parameters.add(parameter);%0A%09%09%7D
  else if
 (tre
@@ -1723,16 +1723,17 @@
  else if
+ 
 (treeNod
@@ -1782,32 +1782,19 @@
 ck%22)) %7B%0A
-                
+%09%09%09
 Block bo
@@ -1829,24 +1829,11 @@
 s);%0A
-                
+%09%09%09
 addC
@@ -1854,46 +1854,22 @@
 y);%0A
-        %7D%0A        else %7B%0A             
+%09%09%7D else %7B%0A%09%09%09
 retu
@@ -1908,26 +1908,14 @@
 e);%0A
-        %7D%0A        
+%09%09%7D%0A%09%09
 retu

Add Parameters to MethodDecl