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

15
LINES

< > BotCompany Repo | #1021003 // tok_crudAutoConstructor

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3524L/21K).

// e.g. class JavaInputConditionToCode extends DynCRUD<Entry>
// => add constructor JavaInputConditionToCode() { super(Entry.class); }

svoid tok_crudAutoConstructor(LS tok) {
  for (int i : jfindAll_reversed(tok, "<id> extends <id>< <id> >", (_tok, nIdx) -> equalsOrStartsWithPlusUnderscore(tok.get(nIdx+5), "DynCRUD"))) {
    S className = tok.get(i), typeName = tok.get(i+8);
    LS body = tok_classBody(tok, i);
    if (!jcontains(body, className + "()", tokcondition {
      ret eqOneOf(_get(tok, i-1), null, "}", ";");
    })) {
      int j = indexOf(tok, "{", i);
      tokAppend_reTok(tok, j, "\n  " + className + "() { super(" + typeName + ".class); }");
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021003
Snippet name: tok_crudAutoConstructor
Eternal ID of this version: #1021003/14
Text MD5: 27e011bc22d1da74b9bd6654dda653dd
Transpilation MD5: 6fb91aac9454fdef744efdb7bb5b9f88
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-03-18 15:38:06
Source code size: 689 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 340 / 975
Version history: 13 change(s)
Referenced in: [show references]