void addRange(Range range, TextSectionMapping mapTable, VmResourceId destinationResource) {
   RangeGroup structure = getSafe(rangeMap, range.start);
   if (structure == null) {
     structure = new RangeGroup();
     this.rangeMap.put(range.start, structure);
   }
   if (range.isEmpty()) {
     structure.emptyRangesAtStart++;
   } else {
     if (structure.nonEmptyRangeMapping != null) {
       throw new RuntimeException();
     }
     structure.nonEmptyRangeMapping = new RangeMapping(range, destinationResource, mapTable);
   }
 }
 public void removeRange(Range range) {
   RangeGroup rangeGroup = rangeMap.get(range.start);
   if (range.isEmpty()) {
     if (rangeGroup.emptyRangesAtStart <= 0) {
       throw new IllegalStateException();
     }
     rangeGroup.emptyRangesAtStart--;
   } else {
     if (rangeGroup.nonEmptyRangeMapping == null
         || !range.equals(rangeGroup.nonEmptyRangeMapping.sourceRange)) {
       throw new IllegalStateException();
     }
     rangeGroup.nonEmptyRangeMapping = null;
   }
   if (rangeGroup.nonEmptyRangeMapping == null && rangeGroup.emptyRangesAtStart == 0) {
     rangeMap.remove(range.start);
   }
 }