package kalang.ast;
import java.util.*;
import javax.annotation.Nullable;
import kalang.core.*;
public class MethodNode extends AstNode implements Annotationable{
    
    public int modifier;
    
    public Type type;
    
    public String name;
    
    public List<ParameterNode> parameters;
    
    public final List<AnnotationNode> annotations = new LinkedList<>();
    
    @Nullable
    public BlockStmt body = null;
    
    public List<Type> exceptionTypes;
    
    public ClassNode classNode;
    
    
    protected MethodNode(ClassNode classNode){
            this.classNode = classNode;
            if(parameters == null) parameters = new LinkedList();
        
            if(exceptionTypes == null) exceptionTypes = new LinkedList();
        
    }
    
    
    protected MethodNode(ClassNode classNode,Integer modifier,Type type,String name,List<ParameterNode> parameters,BlockStmt body,List<Type> exceptionTypes){
        this.classNode = classNode;
            if(parameters == null) parameters = new LinkedList();
            if(exceptionTypes == null) exceptionTypes = new LinkedList();
            this.modifier = modifier;
            this.type = type;
            this.name = name;
            this.parameters = parameters;
            this.body = body;
            this.exceptionTypes = exceptionTypes;
    }
    
    
    protected static MethodNode create(ClassNode classNode){
        MethodNode node = new MethodNode(classNode);
        node.parameters = new LinkedList();
        node.exceptionTypes = new LinkedList();
        return node;
    }
    
    public List<AstNode> getChildren(){
        List<AstNode> ls = new LinkedList();
        addChild(ls,parameters);
        addChild(ls,body);
        return ls;
    }

    @Override
    public AnnotationNode[] getAnnotations() {
        return annotations.toArray(new AnnotationNode[0]);
    }
    
}
@@ -13,16 +13,51 @@
 ng.ast;%0A
+import java.lang.reflect.Modifier;%0A
 import j
@@ -1610,24 +1610,38 @@
 %0A    %7D%0A    %0A
+    @Override%0A
     public L
@@ -1920,19 +1920,363 @@
 e%5B0%5D);%0A    %7D
+%0A%0A    @Override%0A    public String toString() %7B%0A        List%3CString%3E params = new ArrayList();%0A        for(ParameterNode p:parameters)%7B%0A            params.add(String.format(%22%25s %25s%22, p.type,p.name));%0A        %7D%0A        return String.format(%22%25s %25s %25s(%25s)%22, Modifier.toString(modifier),type.toString(),name,String.join(%22,%22, params));%0A    %7D%0A    %0A    
 %0A    %0A%7D

add toString