private void collectRangeMeasures( SMInputCursor function, Map<String, CoverageMeasuresBuilder> coverageData, int conditions, int coveredConditions) throws XMLStreamException { SMInputCursor range = function.childElementCursor("ranges").advance().childElementCursor("range"); CoverageMeasuresBuilder builder = null; String lastSourceId = ""; while (range.getNext() != null) { String sourceId = range.getAttrValue("source_id"); int startLine = Integer.parseInt(range.getAttrValue("start_line")); int endLine = Integer.parseInt(range.getAttrValue("end_line")); int covered = !"no".equalsIgnoreCase(range.getAttrValue("covered")) ? 1 : 0; // value: yes/no/partial if (!sourceId.equals(lastSourceId) || builder == null) { builder = coverageData.get(sourceId); if (builder == null) { builder = CoverageMeasuresBuilder.create(); coverageData.put(sourceId, builder); } builder.setConditions(startLine - 1, conditions, coveredConditions); lastSourceId = sourceId; } while (startLine <= endLine) { builder.setHits(startLine, covered); startLine++; } } }
private static void collectFileMeasures( SMInputCursor clazz, Map<String, CoverageMeasuresBuilder> builderByFilename) throws XMLStreamException { while (clazz.getNext() != null) { String fileName = clazz.getAttrValue("filename"); CoverageMeasuresBuilder builder = builderByFilename.get(fileName); if (builder == null) { builder = CoverageMeasuresBuilder.create(); builderByFilename.put(fileName, builder); } collectFileData(clazz, builder); } }