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

16
LINES

< > BotCompany Repo | #1032611 // tok_shortLambdas

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

Transpiled version (9999L) is out of date.

1  
// "->" short for "() ->"
2  
// "Runnable ->" short for "(Runnable) () ->"
3  
// "-> .x" short for "__0 -> __0.x"
4  
svoid tok_shortLambdas(LS tok) {
5  
  jreplace_dyn(tok, "-> .<id>", (_tok, cIdx) -> {
6  
    var var = makeVar();
7  
    ret var + " -> " + var + "." + _tok.get(cIdx+6);
8  
  });
9  
  
10  
  jreplace(tok, "->", "() ->", tokCondition {
11  
    S prev = _get(tok, i-1);
12  
    ret eqOneOf(prev, null, "=", "(", ",", "return", ":", ">");
13  
  });
14  
  
15  
  jreplace(tok, "Runnable ->", "(Runnable) () ->");
16  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032611
Snippet name: tok_shortLambdas
Eternal ID of this version: #1032611/12
Text MD5: 4dce7825235d3fb896a6289c36ff3433
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-26 22:49:24
Source code size: 494 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 188 / 292
Version history: 11 change(s)
Referenced in: [show references]