Clover coverage report - DynamicJava Test Coverage (dynamicjava-20120303-r5436)
Coverage timestamp: Sat Mar 3 2012 03:02:19 CST
file stats: LOC: 238   Methods: 20
NCLOC: 91   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
MethodDeclaration.java 25% 47.8% 55% 44.2%
coverage coverage
 1    /*
 2    * DynamicJava - Copyright (C) 1999-2001
 3    *
 4    * Permission is hereby granted, free of charge, to any person obtaining a
 5    * copy of this software and associated documentation files
 6    * (the "Software"), to deal in the Software without restriction, including
 7    * without limitation the rights to use, copy, modify, merge, publish,
 8    * distribute, sublicense, and/or sell copies of the Software, and to permit
 9    * persons to whom the Software is furnished to do so, subject to the
 10    * following conditions:
 11    * The above copyright notice and this permission notice shall be included
 12    * in all copies or substantial portions of the Software.
 13    *
 14    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 15    * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 16    * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 17    * IN NO EVENT SHALL DYADE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 18    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 19    * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 20    * DEALINGS IN THE SOFTWARE.
 21    *
 22    * Except as contained in this notice, the name of Dyade shall not be
 23    * used in advertising or otherwise to promote the sale, use or other
 24    * dealings in this Software without prior written authorization from
 25    * Dyade.
 26    *
 27    */
 28   
 29    package koala.dynamicjava.tree;
 30   
 31    import java.util.*;
 32   
 33    import edu.rice.cs.plt.tuple.Option;
 34   
 35    import koala.dynamicjava.tree.tiger.TypeParameter;
 36    import koala.dynamicjava.tree.visitor.*;
 37   
 38    /**
 39    * This class represents method declarations in an AST
 40    *
 41    * @author Stephane Hillion
 42    * @version 1.0 - 1999/05/11
 43    */
 44   
 45    public class MethodDeclaration extends Declaration {
 46   
 47    private Option<List<TypeParameter>> typeParams;
 48    private TypeName returnType;
 49    private String name;
 50    private List<FormalParameter> parameters;
 51    private List<? extends ReferenceTypeName> exceptions;
 52    private BlockStatement body;
 53   
 54    /**
 55    * Creates a new method declaration
 56    * @param mods the modifiers
 57    * @param type the return type of this method
 58    * @param name the name of the method to declare
 59    * @param params the parameters list
 60    * @param excepts the exception list
 61    * @param body the body statement
 62    * @exception IllegalArgumentException if name is null or type is null or
 63    * params is null or excepts is null
 64    */
 65  2 public MethodDeclaration(ModifierSet mods, TypeName type, String name,
 66    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, BlockStatement body) {
 67  2 this(mods, Option.<List<TypeParameter>>none(), type, name, params, excepts, body, SourceInfo.NONE);
 68    }
 69   
 70    /**
 71    * Creates a new method declaration
 72    * @param mods the modifiers
 73    * @param tparams type parameters
 74    * @param type the return type of this method
 75    * @param name the name of the method to declare
 76    * @param params the parameters list
 77    * @param excepts the exception list
 78    * @param body the body statement
 79    * @exception IllegalArgumentException if name is null or type is null or
 80    * params is null or excepts is null
 81    */
 82  0 public MethodDeclaration(ModifierSet mods, Option<List<TypeParameter>> tparams, TypeName type, String name,
 83    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, BlockStatement body) {
 84  0 this(mods, tparams, type, name, params, excepts, body, SourceInfo.NONE);
 85    }
 86   
 87    /**
 88    * Creates a new method declaration
 89    * @param mods the modifiers
 90    * @param type the return type of this method
 91    * @param name the name of the method to declare
 92    * @param params the parameters list
 93    * @param excepts the exception list
 94    * @param body the body statement
 95    * @exception IllegalArgumentException if name is null or type is null or
 96    * params is null or excepts is null
 97    */
 98  0 public MethodDeclaration(ModifierSet mods, TypeName type, String name,
 99    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, BlockStatement body,
 100    SourceInfo si) {
 101  0 this(mods, Option.<List<TypeParameter>>none(), type, name, params, excepts, body, si);
 102    }
 103    /**
 104    * Creates a new method declaration
 105    * @param mods the modifiers
 106    * @param tparams type parameters
 107    * @param type the return type of this method
 108    * @param name the name of the method to declare
 109    * @param params the parameters list
 110    * @param excepts the exception list
 111    * @param body the body statement
 112    * @exception IllegalArgumentException if name is null or type is null or
 113    * params is null or excepts is null
 114    */
 115  345 public MethodDeclaration(ModifierSet mods, Option<List<TypeParameter>> tparams, TypeName type, String name,
 116    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts, BlockStatement body,
 117    SourceInfo si) {
 118  345 super(mods, si);
 119   
 120  0 if (tparams == null) throw new IllegalArgumentException("tparams == null");
 121  0 if (type == null) throw new IllegalArgumentException("type == null");
 122  0 if (name == null) throw new IllegalArgumentException("name == null");
 123  0 if (params == null) throw new IllegalArgumentException("params == null");
 124  0 if (excepts == null) throw new IllegalArgumentException("excepts == null");
 125   
 126  345 typeParams = tparams;
 127  345 returnType = type;
 128  345 this.name = name;
 129  345 parameters = params;
 130  345 this.body = body;
 131  345 exceptions = excepts;
 132    }
 133   
 134  2331 public Option<List<TypeParameter>> getTypeParams() { return typeParams; }
 135  0 public void setTypeArgs(List<TypeParameter> tparams) { typeParams = Option.wrap(tparams); }
 136  0 public void setTypeArgs(Option<List<TypeParameter>> tparams) {
 137  0 if (tparams == null) throw new IllegalArgumentException();
 138  0 typeParams = tparams;
 139    }
 140   
 141    /**
 142    * Gets the return type of this method
 143    */
 144  1017 public TypeName getReturnType() {
 145  1017 return returnType;
 146    }
 147   
 148    /**
 149    * Sets the return type of this method
 150    * @exception IllegalArgumentException if t is null
 151    */
 152  0 public void setReturnType(TypeName t) {
 153  0 if (t == null) throw new IllegalArgumentException("t == null");
 154  0 returnType = t;
 155    }
 156   
 157    /**
 158    * Returns the name of this method
 159    */
 160  776 public String getName() {
 161  776 return name;
 162    }
 163   
 164    /**
 165    * Sets the method's name
 166    * @exception IllegalArgumentException if s is null
 167    */
 168  0 public void setName(String s) {
 169  0 if (s == null) throw new IllegalArgumentException("s == null");
 170  0 name = s;
 171    }
 172   
 173    /**
 174    * Returns the parameters list
 175    */
 176  1873 public List<FormalParameter> getParameters() {
 177  1873 return parameters;
 178    }
 179   
 180    /**
 181    * Sets the parameters list
 182    * @exception IllegalArgumentException if l is null
 183    */
 184  0 public void setParameters(List<FormalParameter> l) {
 185  0 if (l == null) throw new IllegalArgumentException("l == null");
 186  0 parameters = l;
 187    }
 188   
 189    /**
 190    * Returns the list of the exception thrown by this method
 191    * @return a list of string
 192    */
 193  791 public List<? extends ReferenceTypeName> getExceptions() {
 194  791 return exceptions;
 195    }
 196   
 197    /**
 198    * Sets the exceptions list
 199    * @exception IllegalArgumentException if l is null
 200    */
 201  0 public void setExceptions(List<? extends ReferenceTypeName> l) {
 202  0 if (l == null) throw new IllegalArgumentException("l == null");
 203  0 exceptions = l;
 204    }
 205   
 206    /**
 207    * Returns the body of the method, null if the method is abstract
 208    */
 209  982 public BlockStatement getBody() {
 210  982 return body;
 211    }
 212   
 213    /**
 214    * Sets the body
 215    */
 216  0 public void setBody(BlockStatement bs) {
 217  0 body = bs;
 218    }
 219   
 220   
 221    /**
 222    * Allows a visitor to traverse the tree
 223    * @param visitor the visitor to accept
 224    */
 225  952 public <T> T acceptVisitor(Visitor<T> visitor) {
 226  952 return visitor.visit(this);
 227    }
 228    /**
 229    * Implementation of toString for use in unit testing
 230    */
 231  4 public String toString() {
 232  4 return "("+getClass().getName()+": "+toStringHelper()+")";
 233    }
 234   
 235  4 public String toStringHelper() {
 236  4 return getModifiers()+" "+getTypeParams()+" "+getReturnType()+" "+getName()+" "+getParameters()+" "+getExceptions()+" "+getBody();
 237    }
 238    }