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

19
LINES

< > BotCompany Repo | #1022746 // tok_shortVisualize

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

Transpiled version (5793L) is out of date.

// visual bla(super); => visualize { ret bla(super.visualize()); }
// cachedVisual bla(super); => cachedVisualize { ... }
svoid tok_shortVisualize(LS tok) {
  int i = -1;
  while ((i = jfind_any(tok, i+1, "visual <id>", "cachedVisual <id>")) >= 0) {
    int j = tok_findEndOfStatement(tok, i);
    
    for (int k = i; k < j; k += 2)
      if (eqGet(tok, k, "super") && neqGet(tok, k+2, "."))
        tokSet(tok, k, "super.visualize()");
        
    tokSet(tok, j-1, "; }");
    S head = eqGet(tok, i, "cachedVisual")
      ? "cachedVisualize"
      : "visualize";
    tokSet(tok, i, head + " { ret");
    reTok(tok, i, j);
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022746
Snippet name: tok_shortVisualize
Eternal ID of this version: #1022746/6
Text MD5: dda150ba690db95e6c27b376fda92952
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-08 07:19:16
Source code size: 648 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 381 / 478
Version history: 5 change(s)
Referenced in: [show references]