All files / output zcl_abapgit_diff_diff3.clas.mjs

88.06% Statements 155/176
64% Branches 16/25
25% Functions 2/8
88.06% Lines 155/176

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 1761x 1x 1x 1x 1x 1x 1x 1x 1x               1x 1x             1x       1x     1x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 11x 11x 12x 10x 10x 12x   12x     12x 12x 12x 12x 12x 21x 21x 9x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 21x 12x 12x 12x 12x 3x 3x 12x 12x 12x 37x 37x 37x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 37x 4x 4x 4x 4x 4x 4x 4x 4x 33x 29x 29x 29x 29x 29x 29x 29x 29x 29x 37x 37x 12x 12x 21x 12x 12x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_diff_diff3.clas.abap
class zcl_abapgit_diff_diff3 {
  static STATIC_SUPER = undefined;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_DIFF_DIFF3';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"COMPUTE": {"visibility": "U", "parameters": {"RT_DIFF": {"type": () => {return abap.types.TableFactory.construct(new abap.types.Structure({
  "patch_flag": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
  "new_num": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-new_num"}),
  "new": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-NEW"}),
  "result": new abap.types.Character(1, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-result"}),
  "old_num": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-old_num"}),
  "old": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-OLD"}),
  "short": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
  "beacon": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-BEACON"})}, "zif_abapgit_definitions=>ty_diff", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[{"name":"new_num","type":"SORTED","isUnique":false,"keyFields":["NEW_NUM"]},{"name":"old_num","type":"SORTED","isUnique":false,"keyFields":["OLD_NUM"]}]}, "zif_abapgit_definitions=>ty_diffs_tt");}, "is_optional": " ", "parm_kind": "R", "type_name": "TableType"}, "IV_NEW": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "XStringType"}, "IV_OLD": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "XStringType"}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async compute(INPUT) {
    return zcl_abapgit_diff_diff3.compute(INPUT);
  }
  static async compute(INPUT) {
    let rt_diff = abap.types.TableFactory.construct(new abap.types.Structure({
    "patch_flag": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "new_num": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-new_num"}),
    "new": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-NEW"}),
    "result": new abap.types.Character(1, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-result"}),
    "old_num": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-old_num"}),
    "old": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-OLD"}),
    "short": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "beacon": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-BEACON"})}, "zif_abapgit_definitions=>ty_diff", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[{"name":"new_num","type":"SORTED","isUnique":false,"keyFields":["NEW_NUM"]},{"name":"old_num","type":"SORTED","isUnique":false,"keyFields":["OLD_NUM"]}]}, "zif_abapgit_definitions=>ty_diffs_tt");
    let iv_new = INPUT?.iv_new;
    if (iv_new?.getQualifiedName === undefined || iv_new.getQualifiedName() !== "XSTRING") { iv_new = undefined; }
    if (iv_new === undefined) { iv_new = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.iv_new); }
    let iv_old = INPUT?.iv_old;
    if (iv_old?.getQualifiedName === undefined || iv_old.getQualifiedName() !== "XSTRING") { iv_old = undefined; }
    if (iv_old === undefined) { iv_old = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.iv_old); }
    let lv_new = new abap.types.String({qualifiedName: "STRING"});
    let lv_old = new abap.types.String({qualifiedName: "STRING"});
    let lv_new_last = new abap.types.Character(1, {});
    let lv_old_last = new abap.types.Character(1, {});
    let lt_new = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lt_old = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lt_comm = abap.types.TableFactory.construct(new abap.types.Structure({
    "common": abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE"),
    "diff": new abap.types.Structure({
    "buffer1": abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE"),
    "buffer2": abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE")}, "zif_abapgit_diff3=>ty_comm_result-diff", undefined, {}, {})}, "zif_abapgit_diff3=>ty_comm_result", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "zif_abapgit_diff3=>ty_comm_result_t");
    let lo_diff3 = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_DIFF3", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_DIFF3"});
    let ls_comm = new abap.types.Structure({
    "common": abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE"),
    "diff": new abap.types.Structure({
    "buffer1": abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE"),
    "buffer2": abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE")}, "zif_abapgit_diff3=>ty_comm_result-diff", undefined, {}, {})}, "zif_abapgit_diff3=>ty_comm_result", undefined, {}, {});
    let ls_diff = new abap.types.Structure({
    "patch_flag": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "new_num": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-new_num"}),
    "new": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-NEW"}),
    "result": new abap.types.Character(1, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-result"}),
    "old_num": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_definitions=>ty_diff-old_num"}),
    "old": new abap.types.String({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-OLD"}),
    "short": new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}),
    "beacon": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_DIFF-BEACON"})}, "zif_abapgit_definitions=>ty_diff", undefined, {}, {});
    let lt_ins = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lt_del = abap.types.TableFactory.construct(new abap.types.String({qualifiedName: "STRING"}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"isUnique":false,"type":"STANDARD","keyFields":[],"name":"primary_key"},"secondary":[]}, "STRING_TABLE");
    let lv_line = new abap.types.String({qualifiedName: "STRING"});
    let lv_max = new abap.types.Integer({qualifiedName: "I"});
    let lv_new_idx = new abap.types.Integer({qualifiedName: "I"});
    lv_new_idx.set(0);
    let lv_old_idx = new abap.types.Integer({qualifiedName: "I"});
    lv_old_idx.set(0);
    let lv_i = new abap.types.Integer({qualifiedName: "I"});
    rt_diff.clear();
    lv_new.set((await abap.Classes['ZCL_ABAPGIT_CONVERT'].xstring_to_string_utf8({iv_data: iv_new})));
    lv_old.set((await abap.Classes['ZCL_ABAPGIT_CONVERT'].xstring_to_string_utf8({iv_data: iv_old})));
    if (abap.compare.initial(lv_new) === false) {
      lv_new_last.set(abap.builtin.substring({val: lv_new, off: abap.operators.minus(abap.builtin.strlen({val: lv_new}),abap.IntegerFactory.get(1))}));
    }
    if (abap.compare.initial(lv_old) === false) {
      lv_old_last.set(abap.builtin.substring({val: lv_old, off: abap.operators.minus(abap.builtin.strlen({val: lv_old}),abap.IntegerFactory.get(1))}));
    }
    if (abap.compare.eq(lv_new_last, abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline) && abap.compare.ne(lv_old_last, abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline) && abap.compare.initial(lv_old) === false) {
      lv_old.set(abap.operators.concat(lv_old,abap.Classes['CL_ABAP_CHAR_UTILITIES'].form_feed));
    } else if (abap.compare.ne(lv_new_last, abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline) && abap.compare.eq(lv_old_last, abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline) && abap.compare.initial(lv_new) === false) {
      lv_new.set(abap.operators.concat(lv_new,abap.Classes['CL_ABAP_CHAR_UTILITIES'].form_feed));
    }
    abap.statements.split({source: lv_new, at: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, table: lt_new});
    abap.statements.split({source: lv_old, at: abap.Classes['CL_ABAP_CHAR_UTILITIES'].newline, table: lt_old});
    lo_diff3.set((await abap.Classes['ZCL_ABAPGIT_DIFF3'].create()));
    lt_comm.set((await lo_diff3.get().zif_abapgit_diff3$diff_comm({it_buffer1: lt_new, it_buffer2: lt_old})));
    for await (const unique348 of abap.statements.loop(lt_comm)) {
      ls_comm.set(unique348);
      if (abap.compare.initial(ls_comm.get().common) === false) {
        for await (const unique349 of abap.statements.loop(ls_comm.get().common)) {
          lv_line.set(unique349);
          lv_new_idx.set(abap.operators.add(lv_new_idx,abap.IntegerFactory.get(1)));
          lv_old_idx.set(abap.operators.add(lv_old_idx,abap.IntegerFactory.get(1)));
          ls_diff.clear();
          lv_i.set(lv_new_idx);
          ls_diff.get().new_num.set(lv_i);
          lv_i.set(lv_old_idx);
          ls_diff.get().old_num.set(lv_i);
          ls_diff.get().new.set(lv_line);
          ls_diff.get().old.set(lv_line);
          ls_diff.get().result.set(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_diff.get().unchanged);
          abap.statements.append({source: ls_diff, target: rt_diff});
        }
      } else {
        lt_ins.set(ls_comm.get().diff.get().buffer1);
        lt_del.set(ls_comm.get().diff.get().buffer2);
        lv_max.set(abap.builtin.lines({val: lt_ins}));
        if (abap.compare.gt(abap.builtin.lines({val: lt_del}), lv_max)) {
          lv_max.set(abap.builtin.lines({val: lt_del}));
        }
        const indexBackup1 = abap.builtin.sy.get().index.get();
        const unique350 = lv_max.get();
        for (let unique351 = 0; unique351 < unique350; unique351++) {
          abap.builtin.sy.get().index.set(unique351 + 1);
          ls_diff.clear();
          if (abap.compare.le(abap.builtin.sy.get().index, abap.builtin.lines({val: lt_del})) && abap.compare.le(abap.builtin.sy.get().index, abap.builtin.lines({val: lt_ins}))) {
            lv_old_idx.set(abap.operators.add(lv_old_idx,abap.IntegerFactory.get(1)));
            lv_new_idx.set(abap.operators.add(lv_new_idx,abap.IntegerFactory.get(1)));
            lv_i.set(lv_new_idx);
            ls_diff.get().new_num.set(lv_i);
            lv_i.set(lv_old_idx);
            ls_diff.get().old_num.set(lv_i);
            abap.statements.readTable(lt_ins,{index: abap.builtin.sy.get().index,
              into: lv_line});
            if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
              ls_diff.get().new.set(lv_line);
            }
            abap.statements.readTable(lt_del,{index: abap.builtin.sy.get().index,
              into: lv_line});
            if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
              ls_diff.get().old.set(lv_line);
            }
            ls_diff.get().result.set(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_diff.get().update);
          } else if (abap.compare.le(abap.builtin.sy.get().index, abap.builtin.lines({val: lt_del}))) {
            lv_old_idx.set(abap.operators.add(lv_old_idx,abap.IntegerFactory.get(1)));
            abap.statements.readTable(lt_del,{index: abap.builtin.sy.get().index,
              into: lv_line});
            if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
              ls_diff.get().old.set(lv_line);
            }
            ls_diff.get().old_num.set(lv_old_idx);
            ls_diff.get().result.set(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_diff.get().delete);
          } else if (abap.compare.le(abap.builtin.sy.get().index, abap.builtin.lines({val: lt_ins}))) {
            lv_new_idx.set(abap.operators.add(lv_new_idx,abap.IntegerFactory.get(1)));
            abap.statements.readTable(lt_ins,{index: abap.builtin.sy.get().index,
              into: lv_line});
            if (abap.compare.eq(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
              ls_diff.get().new.set(lv_line);
            }
            ls_diff.get().new_num.set(lv_new_idx);
            ls_diff.get().result.set(abap.Classes['ZIF_ABAPGIT_DEFINITIONS'].zif_abapgit_definitions$c_diff.get().insert);
          }
          abap.statements.append({source: ls_diff, target: rt_diff});
        }
        abap.builtin.sy.get().index.set(indexBackup1);
      }
    }
    return rt_diff;
  }
}
abap.Classes['ZCL_ABAPGIT_DIFF_DIFF3'] = zcl_abapgit_diff_diff3;
export {zcl_abapgit_diff_diff3};