public void writeCoverageInfoIfLineStartsANewFieldDeclaration(FileParser fileParser) { if (classAndFieldNames != null && className.equals(fileParser.getCurrentlyPendingClass())) { LineElement initialLineElement = fileParser.lineParser.getInitialElement(); LineElement elementWithFieldName = initialLineElement.findWord(fieldName); if (elementWithFieldName != null) { buildOpeningTagForFieldWrapper(); elementWithFieldName.wrapText(openingTag.toString(), "</span>"); moveToNextField(); } } }
private void buildOpeningTagForFieldWrapper() { openingTag.setLength(0); openingTag.append("<span class='"); StaticFieldData staticData = coverageInfo.getStaticFieldData(classAndFieldNames); boolean staticField = staticData != null; openingTag.append(staticField ? "static" : "instance"); openingTag.append(coverageInfo.isCovered(classAndFieldNames) ? " covered" : " uncovered"); InstanceFieldData instanceData = coverageInfo.getInstanceFieldData(classAndFieldNames); if (staticField || instanceData != null) { openingTag.append("' title='"); appendAccessCounts(staticField ? staticData : instanceData); } openingTag.append("'>"); }
private void appendAccessCounts(FieldData fieldData) { openingTag.append("Reads: ").append(fieldData.getReadCount()); openingTag.append(" Writes: ").append(fieldData.getWriteCount()); }