Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1015567 // Make synonym of function Spike [OK, see makeSFSynonym]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (7977L/55K).

!7

p-experiment {
  makeSFSynonym("setTextAndSelectAll", "setTextSelectAll");
}

svoid makeSFSynonym(S oldName, S newName) {
  S snippetID = stdFunctions_cached().get(oldName);
  if (snippetID == null)
    fail("Standard function " + oldName + " not found");
  L<S> tok = javaTok(loadSnippet
(snippetID));
  LL<S> funcs = findFullFunctionDefs(tok, true);
  new L<S> out;
  for (L<S> tokF : funcs) {
    int i = indexOfAny(tokF, 0, "(", "{");
    if (i < 0) continue;
    S fname = get(tok, i-2);
    if (!eq(fname, oldName)) continue;
    L<S> args = tok_parseArgsList(tokF);
    jreplace(tokF, oldName, newName);
    L<S> start = subList(tok, 0, i);
    bool isVoid = contains(start, "void");
    out.add(join(start) + "(" + joinWithComma(trimAll(map tok_dropFinal(args))) + ") {\n"
      + "  " + (isVoid ? "" : "ret ") + oldName + "(" + joinWithComma(map tok_lastIdentifier(args)) + ");\n"
      + "}");
  }
  print();
  printIndent(joinWithEmptyLines(out));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1015567
Snippet name: Make synonym of function Spike [OK, see makeSFSynonym]
Eternal ID of this version: #1015567/12
Text MD5: 05279b802c03a41a449c2418c057d6d0
Transpilation MD5: 4d35fc8d098d8d9b6bc7cff554770df5
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-17 22:53:20
Source code size: 993 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 469 / 1262
Version history: 11 change(s)
Referenced in: