Clover coverage report - DynamicJava Test Coverage (dynamicjava-20110903-r5436)
Coverage timestamp: Sat Sep 3 2011 03:02:20 CDT
file stats: LOC: 241   Methods: 21
NCLOC: 96   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ConstructorDeclaration.java 10% 40.5% 38.1% 35.3%
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 constructor declarations in an AST
 40    *
 41    * @author Stephane Hillion
 42    * @version 1.0 - 1999/05/23
 43    */
 44   
 45    public class ConstructorDeclaration extends Declaration {
 46    private Option<List<TypeParameter>> typeParams;
 47    private String name;
 48    private List<FormalParameter> parameters;
 49    private List<? extends ReferenceTypeName> exceptions;
 50    private ConstructorCall constructorInvocation; // may be null
 51    private List<Node> statements;
 52   
 53    private boolean varargs;
 54   
 55    /**
 56    * Creates a new method declaration
 57    * @param mods the modifiers
 58    * @param name the name of this constructor
 59    * @param params the parameters list
 60    * @param excepts the exception list (a list of list of token)
 61    * @param eci the explicit constructor invocation
 62    * @param stmts the statements
 63    * @exception IllegalArgumentException if name is null or params is null or
 64    * excepts is null or stmts is null
 65    */
 66  0 public ConstructorDeclaration(ModifierSet mods, String name,
 67    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts,
 68    ConstructorCall eci, List<Node> stmts) {
 69  0 this(mods, Option.<List<TypeParameter>>none(), name, params, excepts, eci, stmts, SourceInfo.NONE);
 70    }
 71   
 72    /**
 73    * Creates a new method declaration
 74    * @param mods the modifiers
 75    * @param tparams the type parameters
 76    * @param name the name of this constructor
 77    * @param params the parameters list
 78    * @param excepts the exception list (a list of list of token)
 79    * @param eci the explicit constructor invocation
 80    * @param stmts the statements
 81    * @exception IllegalArgumentException if name is null or params is null or
 82    * excepts is null or stmts is null
 83    */
 84  0 public ConstructorDeclaration(ModifierSet mods, Option<List<TypeParameter>> tparams, String name,
 85    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts,
 86    ConstructorCall eci, List<Node> stmts) {
 87  0 this(mods, tparams, name, params, excepts, eci, stmts, SourceInfo.NONE);
 88    }
 89   
 90    /**
 91    * Creates a new method declaration
 92    * @param mods the modifiers
 93    * @param name the name of this constructor
 94    * @param params the parameters list
 95    * @param excepts the exception list (a list of list of token)
 96    * @param eci the explicit constructor invocation
 97    * @param stmts the statements
 98    * @exception IllegalArgumentException if name is null or params is null or
 99    * excepts is null or stmts is null
 100    */
 101  0 public ConstructorDeclaration(ModifierSet mods, String name,
 102    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts,
 103    ConstructorCall eci, List<Node> stmts,
 104    SourceInfo si) {
 105  0 this(mods, Option.<List<TypeParameter>>none(), name, params, excepts, eci, stmts, si);
 106    }
 107    /**
 108    * Creates a new method declaration
 109    * @param mods the modifiers
 110    * @param tparams the type parameters
 111    * @param name the name of this constructor
 112    * @param params the parameters list
 113    * @param excepts the exception list (a list of list of token)
 114    * @param eci the explicit constructor invocation
 115    * @param stmts the statements
 116    * @exception IllegalArgumentException if name is null or params is null or
 117    * excepts is null or stmts is null
 118    */
 119  69 public ConstructorDeclaration(ModifierSet mods, Option<List<TypeParameter>> tparams, String name,
 120    List<FormalParameter> params, List<? extends ReferenceTypeName> excepts,
 121    ConstructorCall eci, List<Node> stmts,
 122    SourceInfo si) {
 123  69 super(mods, si);
 124   
 125  69 if (tparams == null || name == null || params == null || excepts == null || stmts == null) {
 126  0 throw new IllegalArgumentException();
 127    }
 128  69 typeParams = tparams;
 129  69 this.name = name;
 130  69 parameters = params;
 131  69 constructorInvocation = eci;
 132  69 statements = stmts;
 133  69 exceptions = excepts;
 134    }
 135   
 136  327 public Option<List<TypeParameter>> getTypeParams() { return typeParams; }
 137  0 public void setTypeArgs(List<TypeParameter> tparams) { typeParams = Option.wrap(tparams); }
 138  0 public void setTypeArgs(Option<List<TypeParameter>> tparams) {
 139  0 if (tparams == null) throw new IllegalArgumentException();
 140  0 typeParams = tparams;
 141    }
 142   
 143    /**
 144    * Returns the name of this constructor
 145    */
 146  69 public String getName() {
 147  69 return name;
 148    }
 149   
 150    /**
 151    * Sets the constructor's name
 152    * @exception IllegalArgumentException if s is null
 153    */
 154  0 public void setName(String s) {
 155  0 if (s == null) throw new IllegalArgumentException("s == null");
 156  0 name = s;
 157    }
 158   
 159    /**
 160    * Returns the parameters list
 161    */
 162  547 public List<FormalParameter> getParameters() {
 163  547 return parameters;
 164    }
 165   
 166    /**
 167    * Sets the parameters
 168    */
 169  0 public void setParameters(List<FormalParameter> l) {
 170  0 parameters = l;
 171    }
 172   
 173    /**
 174    * Returns the list of the exception thrown by this method
 175    * @return a list of string
 176    */
 177  234 public List<? extends ReferenceTypeName> getExceptions() {
 178  234 return exceptions;
 179    }
 180   
 181    /**
 182    * Sets the exceptions thrown by this method
 183    * @exception IllegalArgumentException if l is null
 184    */
 185  0 public void setExceptions(List<? extends ReferenceTypeName> l) {
 186  0 if (l == null) throw new IllegalArgumentException("l == null");
 187  0 exceptions = l;
 188    }
 189   
 190    /**
 191    * The explicit constructor invocation if one or null
 192    */
 193  98 public ConstructorCall getConstructorCall() {
 194  98 return constructorInvocation;
 195    }
 196   
 197    /**
 198    * Sets the constructor invocation
 199    */
 200  0 public void setConstructorCall(ConstructorCall ci) {
 201  0 constructorInvocation = ci;
 202    }
 203   
 204    /**
 205    * Returns the statements
 206    */
 207  100 public List<Node> getStatements() {
 208  100 return statements;
 209    }
 210   
 211    /**
 212    * Sets the statements
 213    * @exception IllegalArgumentException if l is null
 214    */
 215  0 public void setStatements(List<Node> l) {
 216  0 if (l == null) throw new IllegalArgumentException("l == null");
 217  0 statements = l;
 218    }
 219   
 220  0 public boolean isVarArgs(){
 221  0 return varargs;
 222    }
 223   
 224    /**
 225    * Allows a visitor to traverse the tree
 226    * @param visitor the visitor to accept
 227    */
 228  226 public <T> T acceptVisitor(Visitor<T> visitor) {
 229  226 return visitor.visit(this);
 230    }
 231    /**
 232    * Implementation of toString for use in unit testing
 233    */
 234  0 public String toString() {
 235  0 return "("+getClass().getName()+": "+toStringHelper()+")";
 236    }
 237   
 238  0 public String toStringHelper() {
 239  0 return getModifiers()+" "+getName()+" "+getParameters()+" "+getExceptions()+" "+getConstructorCall()+" "+getStatements();
 240    }
 241    }