Clover coverage report - DynamicJava Test Coverage (dynamicjava-20110903-r5436)
Coverage timestamp: Sat Sep 3 2011 03:02:20 CDT
file stats: LOC: 53   Methods: 2
NCLOC: 40   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CompilationUnitChecker.java 0% 0% 0% 0%
coverage
 1    package edu.rice.cs.dynamicjava.sourcechecker;
 2   
 3    import java.util.LinkedList;
 4    import java.util.List;
 5   
 6    import koala.dynamicjava.interpreter.NodeProperties;
 7    import koala.dynamicjava.interpreter.error.ExecutionError;
 8    import koala.dynamicjava.tree.*;
 9    import edu.rice.cs.dynamicjava.Options;
 10    import edu.rice.cs.dynamicjava.interpreter.*;
 11    import edu.rice.cs.plt.collect.UnindexedRelation;
 12    import edu.rice.cs.plt.collect.Relation;
 13    import edu.rice.cs.plt.tuple.Pair;
 14   
 15    public class CompilationUnitChecker {
 16   
 17    /** A context supporting packages and imports, and with access to all types that might be referenced. */
 18    private final TypeContext _context;
 19    private final Options _opt;
 20   
 21  0 public CompilationUnitChecker(TypeContext context, Options opt) {
 22  0 _context = context;
 23  0 _opt = opt;
 24    }
 25   
 26    /**
 27    * Produce a ClassChecker for each TypeDeclaration in the compilation unit.
 28    * @throws InterpreterException If there is an error in the import statements.
 29    */
 30  0 public Relation<TypeDeclaration, ClassChecker> extractDeclarations(CompilationUnit u) throws InterpreterException {
 31  0 TypeContext c = _context;
 32  0 PackageDeclaration pkg = u.getPackage();
 33  0 if (pkg != null) { c = c.setPackage(pkg.getName()); }
 34  0 List<CheckerException> errors = new LinkedList<CheckerException>();
 35  0 for (ImportDeclaration imp : u.getImports()) {
 36  0 try { c = imp.acceptVisitor(new StatementChecker(c, _opt)); }
 37  0 catch (ExecutionError e) { errors.add(new CheckerException(e)); }
 38    }
 39  0 if (!errors.isEmpty()) { throw new CompositeException(errors); }
 40   
 41  0 Relation<TypeDeclaration, ClassChecker> results = UnindexedRelation.makeLinkedHashBased();
 42  0 ClassLoader loader = _context.getClassLoader(); // assumes a single ClassLoader was used for all top-level classes
 43  0 for (Node decl : u.getDeclarations()) {
 44  0 if (decl instanceof TypeDeclaration) {
 45  0 ClassChecker checker = new ClassChecker(NodeProperties.getDJClass(decl), loader, c, _opt);
 46  0 results.add(Pair.make((TypeDeclaration) decl, checker));
 47    }
 48  0 else { throw new RuntimeException("Unrecognized compilation unit declaration"); }
 49    }
 50  0 return results;
 51    }
 52   
 53    }