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.

// "->" short for "() ->"
// "Runnable ->" short for "(Runnable) () ->"
// "-> .x" short for "__0 -> __0.x"
svoid tok_shortLambdas(LS tok) {
  jreplace_dyn(tok, "-> .<id>", (_tok, cIdx) -> {
    var var = makeVar();
    ret var + " -> " + var + "." + _tok.get(cIdx+6);
  });
  
  jreplace(tok, "->", "() ->", tokCondition {
    S prev = _get(tok, i-1);
    ret eqOneOf(prev, null, "=", "(", ",", "return", ":", ">");
  });
  
  jreplace(tok, "Runnable ->", "(Runnable) () ->");
}

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: 63 / 135
Version history: 11 change(s)
Referenced in: [show references]