// 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, _iLastName = i+4; while (eqGet(tok, _iLastName+2, "aka") && isIdentifier(get(tok, _iLastName+4))) _iLastName += 4; int iLastName = _iLastName; // find arguments int iOpening = indexOf(tok, iLastName, "("); int iClosing = findEndOfBracketPart2(tok, iOpening)-1; // find all names new LS names; for (int j = iName1; j <= iLastName; j += 4) names.add(tok.get(j)); // find return type & modifiers int iType = tok_leftScanType(tok, iName1); int iStart = leftScanModifiers(tok, tok_leftScanTypeArgsOpt(tok, iType)); // parse argument list LS _args = subList(tok, iOpening+1, iClosing); LS args = tok_parseArgsDeclList2(_args); // analyze return type LS type = subList(tok, iType-1, iName1); // return type bool isVoid = containsOneOf(codeTokens(type), javaxVoidAliases()); // drop all but first name clearTokens(tok, iName1+1, iLastName+1); // add synonyms tokPrepend_reTok(tok, iStart, joinMap(dropFirst(names), name -> joinSubList(tok, iStart, iName1) + name + joinSubList(tok, iLastName+1, iClosing+1) + " { " + stringIf(!isVoid, "return ") + first(names) + "(" + joinWithComma(lmap tok_lastIdentifier(args)) + "); }\n")); } }