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

22
LINES

< > BotCompany Repo | #1033170 // tok_reImmutableVars

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

Transpiled version (5670L) is out of date.

1  
// turns out reMutable and reImmutable are the same thing :)
2  
// TODO: handle this.myVar
3  
svoid tok_reImmutableVars(LS tok) {
4  
  tok_unifyKeywords(tok, remutableKeywords(), "reImmutable");
5  
      
6  
  // without assignment
7  
  jreplace_dyn(tok, "reImmutable <id>;", (_tok, i) -> {
8  
    S var = _get(tok, i+2);
9  
    S var2 = makeVar(var);
10  
    ret "var \*var2*/ = \*var*/; replace var \*var*/ with \*var2*/.\n";
11  
  });
12  
  
13  
  // with assignment
14  
  for (int i : jfind_all_reversed(tok, "reImmutable <id> =")) {
15  
    S var = _get(tok, i+2);
16  
    S var2 = makeVar(var);
17  
    int j = tok_endOfStatement(tok, i+6);
18  
    S expr = joinSubList(tok, i+6, j-1);
19  
    tokReplace_reTok(tok, i, j,
20  
      "var \*var2*/ = \*expr*/; replace var \*var*/ with \*var2*/.\n");
21  
  }
22  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033170
Snippet name: tok_reImmutableVars
Eternal ID of this version: #1033170/12
Text MD5: 400bdad3f58ecc1eac35f1efd6d02ff0
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-15 03:07:56
Source code size: 764 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 205 / 343
Version history: 11 change(s)
Referenced in: [show references]