// e.g. // void tailCall aka replace(Computable x) {...} // to: // void tailCall(Computable x) {...} // void replace(Computable x) { tailCall(x); } // (or the other way around) svoid tok_akaFunctionNames(LS tok) { int i; while ((i = jfind(tok, "<id> aka <id>")) >= 0) { int iName1 = i, iName2 = i+4; int iOpening = indexOf(tok, i, "("); int iClosing = findEndOfBracketPart2(tok, iOpening)-1; S name1 = tok.get(iName1), name2 = tok.get(iName2); int iType = tok_leftScanType(tok, iName1); int iStart = tok_leftScanTypeArgsOpt(tok, iType); iStart = leftScanModifiers(tok, iStart); LS _args = subList(tok, iOpening+1, iClosing); LS args = tok_parseArgsDeclList2(_args); LS type = subList(tok, iType-1, iName1); // return type bool isVoid = containsOneOf(codeTokens(type), javaxVoidAliases()); // replace "aka" with params, body and modifiers+return type replaceTokens(tok, iName1+1, iName1+4, joinSubList(tok, iOpening, iClosing+1) + " { " + stringIf(!isVoid, "return ") + name2 + "(" + joinWithComma(lmap tok_lastIdentifier(args)) + "); }\n" + join(dropFirst(type))); } }
Began life as a copy of #1030979
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030981 |
Snippet name: | tok_akaFunctionNames [backup before multiple akas] |
Eternal ID of this version: | #1030981/3 |
Text MD5: | 49115f22805bae0865644bfbcb4c84c2 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-04-18 03:54:18 |
Source code size: | 1203 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 154 / 186 |
Version history: | 2 change(s) |
Referenced in: | -