Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1017958 - tok_addFieldOrder

JavaX fragment (include)

static void tok_addFieldOrder(L<S> tok, int i) {
  if (!contains(tok_modifiersLeftOf(tok, i), "static")) ret; // no static fields allowed in non-static classes (for whatever reason)
  int idx = findCodeTokens(tok, i, false, "{");
  if (idx < 0) ret;
  int j = findEndOfBracketPart(tok, idx);
  L<S> vars = allVarNames(subList(tok, idx+1, j-1));
  //print("addFieldOrder " + struct(vars));
  if (nempty(vars) && !vars.contains("_fieldOrder")
    && !isSortedList(vars)) {
    print("Adding field order");
    tok.set(idx+2, "static final String _fieldOrder = " + quote(join(" ", vars)) + ";\n  " + tok.get(idx+2));
    // reTok has to be done by caller
  }
}

download  show line numbers  debug dex   

Travelled to 9 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1017958
Snippet name: tok_addFieldOrder
Eternal ID of this version: #1017958/4
Text MD5: 0f8142a1b79eccd61a40f69d19b25d62
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-21 19:59:50
Source code size: 670 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 181 / 172
Version history: 3 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1017958 & http://1017958.tinybrain.de