void printMethodCoverages(ClassCoverage cc) { String space = " "; boolean result = true; if (cc.methods == null) { return; } ArrayList<Map.Entry<MethodInfo, MethodCoverage>> mthEntries = Misc.createSortedEntryList( cc.methods, new Comparator<Map.Entry<MethodInfo, MethodCoverage>>() { public int compare( Map.Entry<MethodInfo, MethodCoverage> o1, Map.Entry<MethodInfo, MethodCoverage> o2) { int a = o2.getValue().getCoveredInsn().percent(); int b = o1.getValue().getCoveredInsn().percent(); if (a == b) { return o2.getKey().getUniqueName().compareTo(o1.getKey().getUniqueName()); } else { return a - b; } } }); Coverage emptyCoverage = new Coverage(0, 0); for (Map.Entry<MethodInfo, MethodCoverage> e : mthEntries) { MethodCoverage mc = e.getValue(); MethodInfo mi = mc.getMethodInfo(); Coverage insnCoverage = mc.getCoveredInsn(); Coverage lineCoverage = mc.getCoveredLines(); Coverage branchCoverage = mc.getCoveredBranches(); result = result && insnCoverage.isFullyCovered(); pw.print(space); printCoverage(insnCoverage); pw.print(space); printCoverage(lineCoverage); pw.print(space); printCoverage(mc.getCoveredBasicBlocks()); pw.print(space); printCoverage(branchCoverage); pw.print(space); printCoverage(emptyCoverage); pw.print(space); pw.print(mi.getLongName()); pw.println(); if (showMethodBodies && (!insnCoverage.isFullyCovered() || !branchCoverage.isFullyCovered())) { printBodyCoverage(mc); } } }
void printMethodCoverages(ClassCoverage cc) { String classNameTree = "cc-" + cc.className.replace('.', '-') + '-'; int line, lineNumbers[]; boolean result = true; if (cc.methods == null) { return; } ArrayList<Map.Entry<MethodInfo, MethodCoverage>> mthEntries = Misc.createSortedEntryList( cc.methods, new Comparator<Map.Entry<MethodInfo, MethodCoverage>>() { public int compare( Map.Entry<MethodInfo, MethodCoverage> o1, Map.Entry<MethodInfo, MethodCoverage> o2) { int a = o2.getValue().getCoveredInsn().percent(); int b = o1.getValue().getCoveredInsn().percent(); if (a == b) { return o2.getKey().getUniqueName().compareTo(o1.getKey().getUniqueName()); } else { return a - b; } } }); for (Map.Entry<MethodInfo, MethodCoverage> e : mthEntries) { MethodCoverage mc = e.getValue(); MethodInfo mi = mc.getMethodInfo(); Coverage insnCoverage = mc.getCoveredInsn(); Coverage lineCoverage = mc.getCoveredLines(); Coverage branchCoverage = mc.getCoveredBranches(); result = result && insnCoverage.isFullyCovered(); HTMLPublisher.writeTableTreeNodeBegin( pw, classNameTree + HTMLPublisher.escape(mi.getLongName())); pw.print(" <td class=\"firstCol\">"); lineNumbers = mi.getLineNumbers(); if ((lineNumbers != null) && (lineNumbers.length > 0)) { line = lineNumbers[0]; } else { line = 0; } ((HTMLPublisher) publisher).writeSourceAnchor(pw, mi.getSourceFileName(), line); pw.print(HTMLPublisher.escape(mi.getLongName())); pw.println("</a></td>"); pw.print(" "); printCoverage(insnCoverage); printCoverage(lineCoverage); printCoverage(mc.getCoveredBasicBlocks()); printCoverage(branchCoverage); pw.println(); HTMLPublisher.writeTableTreeNodeEnd(pw); } }