private void instrumentBranchCoverage(NodeTraversal traversal, FileInstrumentationData data) {
    int maxLine = data.maxBranchPresentLine();
    int branchCoverageOffset = 0;
    for (int lineIdx = 1; lineIdx <= maxLine; ++lineIdx) {
      Integer numBranches = data.getNumBranches(lineIdx);
      if (numBranches != null) {
        for (int branchIdx = 1; branchIdx <= numBranches; ++branchIdx) {
          Node block = data.getBranchNode(lineIdx, branchIdx);
          block.addChildToFront(
              newBranchInstrumentationNode(traversal, block, branchCoverageOffset + branchIdx - 1));
          compiler.reportChangeToEnclosingScope(block);
        }
        branchCoverageOffset += numBranches;
      }
    }
  }
private void instrumentBranchCoverage ( NodeTraversal traversal , FileInstrumentationData data ) { int maxLine = data . maxBranchPresentLine ( ) ; int branchCoverageOffset = 0 ; for ( int lineIdx = 1 ; lineIdx <= maxLine ; ++ lineIdx ) { Integer numBranches = data . getNumBranches ( lineIdx ) ; if ( numBranches != null ) { for ( int branchIdx = 1 ; branchIdx <= numBranches ; ++ branchIdx ) { Node block = data . getBranchNode ( lineIdx , branchIdx ) ; block . addChildToFront ( newBranchInstrumentationNode ( traversal , block , branchCoverageOffset + branchIdx - 1 ) ) ; compiler . reportChangeToEnclosingScope ( block ) ; } branchCoverageOffset += numBranches ; } } }
Add instrumentation code for branch coverage. For each block that correspond to a branch,
insert an assignment of the branch coverage data to the front of the block.