// 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, " aka ")) >= 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))); } }