protected void saveClass()

in instrumentation/src/com/intellij/rt/coverage/util/InstructionsSection.java [95:131]


  protected void saveClass(ClassData classData, DataOutput out, int index) throws IOException {
    final LineData[] lines = (LineData[]) classData.getLines();
    if (lines == null) return;
    final ClassInstructions classInstructions = myProjectData.getInstructions().get(classData.getName());
    if (classInstructions == null) {
      int lineCount = 0;
      for (LineData lineData : lines) {
        if (lineData != null) {
          lineCount++;
        }
      }
      ErrorReporter.info("Class " + classData.getName() + " does not have instructions info, while there are " +
          lineCount + " lines available", new Throwable());
      return;
    }
    CoverageIOUtil.writeINT(out, index);
    final LineInstructions[] lineInstructions = classInstructions.getlines();
    for (int line = 0; line < lines.length; line++) {
      final LineData lineData = lines[line];
      if (lineData == null) continue;
      final LineInstructions lineInstruction = line >= lineInstructions.length ? null : lineInstructions[line];
      CoverageIOUtil.writeINT(out, lineInstruction == null ? 0 : lineInstruction.getInstructions());
      final List<JumpInstructions> jumps = lineInstruction == null ? null : lineInstruction.getJumps();
      for (int i = 0; i < lineData.jumpsCount(); i++) {
        final JumpInstructions jumpInstructions = jumps == null || i >= jumps.size() ? null : jumps.get(i);
        CoverageIOUtil.writeINT(out, jumpInstructions == null ? 0 : jumpInstructions.getInstructions(true));
        CoverageIOUtil.writeINT(out, jumpInstructions == null ? 0 : jumpInstructions.getInstructions(false));
      }
      final List<SwitchInstructions> switches = lineInstruction == null ? null : lineInstruction.getSwitches();
      for (int i = 0; i < lineData.switchesCount(); i++) {
        final SwitchInstructions switchInstructions = switches == null || i >= switches.size() ? null : switches.get(i);
        for (int key = -1; key < lineData.getSwitchData(i).getKeys().length; key++) {
          CoverageIOUtil.writeINT(out, switchInstructions == null ? 0 : switchInstructions.getInstructions(key));
        }
      }
    }
  }