All files / output zcl_abapgit_syntax_xml.clas.mjs

81.46% Statements 145/178
83.87% Branches 26/31
40% Functions 6/15
81.46% Lines 145/178

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 176 177 1781x 1x 1x 1x 1x 1x 1x 1x 1x       1x 1x       1x 1x       1x 1x 1x 1x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 18x 1x 18x 18x 18x 18x 18x 18x 18x 18x 1x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x                           20x 75x 75x 75x 75x 75x 33x 33x 7x 7x 7x 7x 33x 8x 8x 7x 7x 7x 26x 18x 18x 75x 1x 1x 1x 1x 1x 1x                   42x 41x 10x 10x 41x 1x 1x 1x 41x 67x 67x 67x 20x 1x 1x     1x 20x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
const {zcl_abapgit_syntax_highlighter} = await import("./zcl_abapgit_syntax_highlighter.clas.mjs");
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_syntax_xml.clas.abap
class zcl_abapgit_syntax_xml extends zcl_abapgit_syntax_highlighter {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_SYNTAX_XML';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"GV_COMMENT": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "visibility": "O", "is_constant": " ", "is_class": "X"},
  "C_CSS": {"type": () => {return new abap.types.Structure({
  "xml_tag": new abap.types.String({qualifiedName: "STRING"}),
  "attr": new abap.types.String({qualifiedName: "STRING"}),
  "attr_val": new abap.types.String({qualifiedName: "STRING"}),
  "comment": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});}, "visibility": "U", "is_constant": "X", "is_class": "X"},
  "C_TOKEN": {"type": () => {return new abap.types.Structure({
  "xml_tag": new abap.types.Character(1, {}),
  "attr": new abap.types.Character(1, {}),
  "attr_val": new abap.types.Character(1, {}),
  "comment": new abap.types.Character(1, {})}, undefined, undefined, {}, {});}, "visibility": "U", "is_constant": "X", "is_class": "X"},
  "C_REGEX": {"type": () => {return new abap.types.Structure({
  "xml_tag": new abap.types.String({qualifiedName: "STRING"}),
  "attr": new abap.types.String({qualifiedName: "STRING"}),
  "attr_val": new abap.types.String({qualifiedName: "STRING"}),
  "comment": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});}, "visibility": "U", "is_constant": "X", "is_class": "X"}};
  static METHODS = {"ORDER_MATCHES": {"visibility": "O", "parameters": {}},
  "CONSTRUCTOR": {"visibility": "U", "parameters": {}}};
  constructor() {
    const sup = super();
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "SUPER": sup.FRIENDS_ACCESS_INSTANCE,
      "order_matches": this.order_matches.bind(this),
    };
    this.gv_comment = zcl_abapgit_syntax_xml.gv_comment;
    this.c_css = zcl_abapgit_syntax_xml.c_css;
    this.c_token = zcl_abapgit_syntax_xml.c_token;
    this.c_regex = zcl_abapgit_syntax_xml.c_regex;
  }
  async constructor_(INPUT) {
    await super.constructor_();
    zcl_abapgit_syntax_xml.gv_comment.clear();
    await this.add_rule({iv_regex: zcl_abapgit_syntax_xml.c_regex.get().xml_tag, iv_token: zcl_abapgit_syntax_xml.c_token.get().xml_tag, iv_style: zcl_abapgit_syntax_xml.c_css.get().xml_tag, iv_submatch: abap.IntegerFactory.get(1)});
    await this.add_rule({iv_regex: zcl_abapgit_syntax_xml.c_regex.get().attr, iv_token: zcl_abapgit_syntax_xml.c_token.get().attr, iv_style: zcl_abapgit_syntax_xml.c_css.get().attr});
    await this.add_rule({iv_regex: zcl_abapgit_syntax_xml.c_regex.get().attr_val, iv_token: zcl_abapgit_syntax_xml.c_token.get().attr_val, iv_style: zcl_abapgit_syntax_xml.c_css.get().attr_val});
    await this.add_rule({iv_regex: zcl_abapgit_syntax_xml.c_regex.get().comment, iv_token: zcl_abapgit_syntax_xml.c_token.get().comment, iv_style: zcl_abapgit_syntax_xml.c_css.get().comment});
    return this;
  }
  async order_matches(INPUT) {
    let iv_line = INPUT?.iv_line;
    if (iv_line?.getQualifiedName === undefined || iv_line.getQualifiedName() !== "STRING") { iv_line = undefined; }
    if (iv_line === undefined) { iv_line = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_line); }
    let ct_matches = abap.types.TableFactory.construct(new abap.types.Structure({
    "token": new abap.types.Character(1, {"qualifiedName":"zcl_abapgit_syntax_highlighter=>ty_match-token"}),
    "offset": new abap.types.Integer({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-OFFSET"}),
    "length": new abap.types.Integer({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-LENGTH"}),
    "text_tag": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-TEXT_TAG"})}, "zcl_abapgit_syntax_highlighter=>ty_match", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "zcl_abapgit_syntax_highlighter=>ty_match_tt");
    if (INPUT && INPUT.ct_matches) {ct_matches = INPUT.ct_matches;}
    let lv_match = new abap.types.String({qualifiedName: "STRING"});
    let lv_line_len = new abap.types.Integer({qualifiedName: "I"});
    let lv_cmmt_end = new abap.types.Integer({qualifiedName: "I"});
    let lv_index = new abap.types.Integer({qualifiedName: "I"});
    let lv_prev_token = new abap.types.Character(1, {});
    let lv_state = new abap.types.Character(1, {});
    lv_state.set('O');
    let fs_ls_prev_ = new abap.types.FieldSymbol(new abap.types.Structure({
    "token": new abap.types.Character(1, {"qualifiedName":"zcl_abapgit_syntax_highlighter=>ty_match-token"}),
    "offset": new abap.types.Integer({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-OFFSET"}),
    "length": new abap.types.Integer({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-LENGTH"}),
    "text_tag": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-TEXT_TAG"})}, "zcl_abapgit_syntax_highlighter=>ty_match", undefined, {}, {}));
    let fs_ls_match_ = new abap.types.FieldSymbol(new abap.types.Structure({
    "token": new abap.types.Character(1, {"qualifiedName":"zcl_abapgit_syntax_highlighter=>ty_match-token"}),
    "offset": new abap.types.Integer({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-OFFSET"}),
    "length": new abap.types.Integer({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-LENGTH"}),
    "text_tag": new abap.types.String({qualifiedName: "ZCL_ABAPGIT_SYNTAX_HIGHLIGHTER=>TY_MATCH-TEXT_TAG"})}, "zcl_abapgit_syntax_highlighter=>ty_match", undefined, {}, {}));
    abap.statements.sort(ct_matches,{by: [{component: "offset"}]});
    lv_line_len.set(abap.builtin.strlen({val: iv_line}));
    if (abap.compare.eq(zcl_abapgit_syntax_xml.gv_comment, abap.builtin.abap_true)) {
      abap.statements.readTable(ct_matches,{withKey: (i) => {return abap.compare.eq(i.token, zcl_abapgit_syntax_xml.c_token.get().comment);},
        withKeyValue: [{key: (i) => {return i.token}, value: zcl_abapgit_syntax_xml.c_token.get().comment}],
        usesTableLine: false,
        withKeySimple: {"token": zcl_abapgit_syntax_xml.c_token.get().comment}});
      if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
        ct_matches.clear();
        fs_ls_match_.assign(ct_matches.appendInitial());
        fs_ls_match_.get().token.set(zcl_abapgit_syntax_xml.c_token.get().comment);
        fs_ls_match_.get().offset.set(abap.IntegerFactory.get(0));
        fs_ls_match_.get().length.set(lv_line_len);
        return;
      }
    }
    for await (const unique661 of abap.statements.loop(ct_matches)) {
      fs_ls_match_.assign(unique661);
      lv_index.set(abap.builtin.sy.get().tabix);
      lv_match.set(abap.builtin.substring({val: iv_line, off: fs_ls_match_.get().offset, len: fs_ls_match_.get().length}));
      let unique662 = fs_ls_match_.get().token;
      if (abap.compare.eq(unique662, zcl_abapgit_syntax_xml.c_token.get().xml_tag)) {
        fs_ls_match_.get().text_tag.set(lv_match);
        if (abap.compare.eq(fs_ls_match_.get().text_tag, abap.CharacterFactory.get(1, '>')) && abap.compare.eq(lv_prev_token, zcl_abapgit_syntax_xml.c_token.get().xml_tag)) {
          lv_state.set(abap.CharacterFactory.get(1, 'C'));
          fs_ls_prev_.get().length.set(abap.operators.add(abap.operators.minus(fs_ls_match_.get().offset,fs_ls_prev_.get().offset),fs_ls_match_.get().length));
          await abap.statements.deleteInternal(ct_matches,{index: lv_index});
          continue;
        } else if (abap.compare.eq(fs_ls_match_.get().text_tag, abap.CharacterFactory.get(1, '>')) && abap.compare.ne(lv_prev_token, zcl_abapgit_syntax_xml.c_token.get().xml_tag)) {
          lv_state.set(abap.CharacterFactory.get(1, 'C'));
          if (abap.compare.assigned(fs_ls_prev_)) {
            fs_ls_match_.get().length.set(abap.operators.add(abap.operators.minus(abap.operators.minus(fs_ls_match_.get().offset,fs_ls_prev_.get().offset),fs_ls_prev_.get().length),fs_ls_match_.get().length));
            fs_ls_match_.get().offset.set(abap.operators.add(fs_ls_prev_.get().offset,fs_ls_prev_.get().length));
          }
        } else {
          lv_state.set(abap.CharacterFactory.get(1, 'O'));
        }
      } else if (abap.compare.eq(unique662, zcl_abapgit_syntax_xml.c_token.get().comment)) {
        if (abap.compare.eq(lv_match, abap.CharacterFactory.get(4, '<!--'))) {
          await abap.statements.deleteInternal(ct_matches,{where: async (I) => {return abap.compare.gt(I.offset, fs_ls_match_.get().offset);}});
          await abap.statements.deleteInternal(ct_matches,{where: async (I) => {return abap.compare.eq(I.offset, fs_ls_match_.get().offset) && abap.compare.eq(I.token, zcl_abapgit_syntax_xml.c_token.get().xml_tag);}});
          fs_ls_match_.get().length.set(abap.operators.minus(lv_line_len,fs_ls_match_.get().offset));
          zcl_abapgit_syntax_xml.gv_comment.set(abap.builtin.abap_true);
        } else if (abap.compare.eq(lv_match, abap.CharacterFactory.get(3, '-->'))) {
          await abap.statements.deleteInternal(ct_matches,{where: async (I) => {return abap.compare.lt(I.offset, fs_ls_match_.get().offset);}});
          fs_ls_match_.get().length.set(abap.operators.add(fs_ls_match_.get().offset,abap.IntegerFactory.get(3)));
          fs_ls_match_.get().offset.set(abap.IntegerFactory.get(0));
          zcl_abapgit_syntax_xml.gv_comment.set(abap.builtin.abap_false);
        } else {
          lv_cmmt_end.set(abap.operators.add(fs_ls_match_.get().offset,fs_ls_match_.get().length));
          await abap.statements.deleteInternal(ct_matches,{where: async (I) => {return abap.compare.gt(I.offset, fs_ls_match_.get().offset) && abap.compare.le(I.offset, lv_cmmt_end);}});
          await abap.statements.deleteInternal(ct_matches,{where: async (I) => {return abap.compare.eq(I.offset, fs_ls_match_.get().offset) && abap.compare.eq(I.token, zcl_abapgit_syntax_xml.c_token.get().xml_tag);}});
        }
      } else {
        if (abap.compare.eq(lv_prev_token, zcl_abapgit_syntax_xml.c_token.get().xml_tag)) {
          fs_ls_prev_.get().length.set(abap.operators.minus(fs_ls_match_.get().offset,fs_ls_prev_.get().offset));
        }
        if (abap.compare.eq(lv_state, abap.CharacterFactory.get(1, 'C'))) {
          await abap.statements.deleteInternal(ct_matches,{index: lv_index});
          continue;
        }
      }
      lv_prev_token.set(fs_ls_match_.get().token);
      abap.statements.assign({target: fs_ls_prev_, source: fs_ls_match_});
    }
    if (abap.compare.eq(lv_prev_token, zcl_abapgit_syntax_xml.c_token.get().xml_tag) && abap.compare.assigned(fs_ls_prev_) && abap.compare.eq(fs_ls_prev_.get().length, abap.IntegerFactory.get(1)) && abap.compare.eq(fs_ls_prev_.get().text_tag, abap.CharacterFactory.get(1, '<'))) {
      abap.statements.find(iv_line.getOffset({offset: fs_ls_prev_.get().offset}), {regex: abap.CharacterFactory.get(10, '<\\s*[^\\s]*'), length: fs_ls_prev_.get().length});
      if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
        fs_ls_prev_.get().length.set(abap.IntegerFactory.get(1));
      }
    }
  }
}
abap.Classes['ZCL_ABAPGIT_SYNTAX_XML'] = zcl_abapgit_syntax_xml;
zcl_abapgit_syntax_xml.gv_comment = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
zcl_abapgit_syntax_xml.c_css = new abap.types.Structure({
"xml_tag": new abap.types.String({qualifiedName: "STRING"}),
"attr": new abap.types.String({qualifiedName: "STRING"}),
"attr_val": new abap.types.String({qualifiedName: "STRING"}),
"comment": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});
zcl_abapgit_syntax_xml.c_css.get().xml_tag.set('xml_tag');
zcl_abapgit_syntax_xml.c_css.get().attr.set('attr');
zcl_abapgit_syntax_xml.c_css.get().attr_val.set('attr_val');
zcl_abapgit_syntax_xml.c_css.get().comment.set('comment');
zcl_abapgit_syntax_xml.c_token = new abap.types.Structure({
"xml_tag": new abap.types.Character(1, {}),
"attr": new abap.types.Character(1, {}),
"attr_val": new abap.types.Character(1, {}),
"comment": new abap.types.Character(1, {})}, undefined, undefined, {}, {});
zcl_abapgit_syntax_xml.c_token.get().xml_tag.set('X');
zcl_abapgit_syntax_xml.c_token.get().attr.set('A');
zcl_abapgit_syntax_xml.c_token.get().attr_val.set('V');
zcl_abapgit_syntax_xml.c_token.get().comment.set('C');
zcl_abapgit_syntax_xml.c_regex = new abap.types.Structure({
"xml_tag": new abap.types.String({qualifiedName: "STRING"}),
"attr": new abap.types.String({qualifiedName: "STRING"}),
"attr_val": new abap.types.String({qualifiedName: "STRING"}),
"comment": new abap.types.String({qualifiedName: "STRING"})}, undefined, undefined, {}, {});
zcl_abapgit_syntax_xml.c_regex.get().xml_tag.set('(?:"[^"]*")|(?:\'[^\']*\')|(?:`[^`]*`)|([<>])');
zcl_abapgit_syntax_xml.c_regex.get().attr.set('(?:^|\\s)[-a-z:_0-9]+\\s*(?==\\s*["|\'|`])');
zcl_abapgit_syntax_xml.c_regex.get().attr_val.set('("[^"]*")|(\'[^\']*\')|(`[^`]*`)');
zcl_abapgit_syntax_xml.c_regex.get().comment.set('[\\<]!--.*--[\\>]|[\\<]!--|--[\\>]');
export {zcl_abapgit_syntax_xml};