sS makeSFSynonym(S oldName, S newName) { if (eq(oldName, newName)) fail("Can't make a synonym of itself"); stdFunctions_clearCache(); S snippetID = stdFunctions_cached().get(oldName); if (snippetID == null) { snippetID = stdFunctions_cached().get(newName); if (snippetID == null) fail("Standard function " + oldName + " not found"); S temp = oldName; oldName = newName; newName = temp; } L tok = javaTok(loadSnippet(snippetID)); LL funcs = findFullFunctionDefs(tok, true); new L out; for (L tokF : funcs) { int i = indexOfAny(tokF, 0, "(", "{"); if (i < 0) continue; S fname = get(tokF, i-2); if (!eq(fname, oldName)) continue; L args = tok_parseArgsDeclList(tokF); jreplace(tokF = cloneList(tokF), oldName, newName); L start = cloneList(subList(tokF, 0, i)); jreplace(start, "synchronized", ""); bool isVoid = containsOneOf(start, "void", "svoid"); out.add(join(start) + "(" + joinWithComma(trimAll(map tok_dropFinal(args))) + ") {\n" + " " + (isVoid ? "" : "ret ") + oldName + "(" + joinWithComma(lmap tok_nameOfParam(args)) + ");\n" + "}"); } if (empty(out)) fail("No functions found"); print(); S src = joinWithEmptyLines(out); printIndent(src); if (isStandardFunction(newName)) { S snippetID2 = sfSnippet(newName); S result = editSnippet(snippetID2, src); ret print("Standard function " + newName + " exists, edited " + snippetID2 + ": " + result); } S newSnippetID = createSnippet(src, newName + " - synonym of " + oldName, snippetType_JavaXInclude()); checkMarkAnimation_bottomLeft(addStdFunction(newSnippetID, true), 2); stdFunctions_clearCache(); ret "Synonym made!"; }