Libraryless. Click here for Pure Java version (13010L/87K).
| 1 | // add latest include | 
| 2 | static S addStdClass() {
 | 
| 3 |   loading {
 | 
| 4 | ret addStdClass(findLatestInclude().id, true); | 
| 5 | } | 
| 6 | } | 
| 7 | |
| 8 | static S addStdClass(bool realEdit) {
 | 
| 9 | ret addStdClass(findLatestInclude().id, realEdit); | 
| 10 | } | 
| 11 | |
| 12 | static S addStdClass(S snippetID, bool realEdit) {
 | 
| 13 |   loading {
 | 
| 14 | snippetID = fsI(snippetID); | 
| 15 | LS tok = javaTokSnippet(snippetID); | 
| 16 | L<S> names = map getClassDeclarationName(allClasses(tok)); | 
| 17 | addAll(names, keys(tok_findRewrites(tok))); | 
| 18 |     printStructure("Classes defined in " + snippetID + ": ", names);
 | 
| 19 | if (empty(names)) ret "No classes found in " + snippetID; | 
| 20 | S name = first(names); | 
| 21 | |
| 22 | S text = loadSnippet(#1003674); | 
| 23 | SS map = standardClassesMap_uncached(); | 
| 24 | S def = map.get(name); | 
| 25 | S result = ""; | 
| 26 |     if (def == null) {
 | 
| 27 | print(result = "Defining " + name + "."); | 
| 28 | |
| 29 | S newText = addToStdClassesList(text, name, snippetID); | 
| 30 | print(); | 
| 31 | print(unidiff(text, newText)); | 
| 32 | if (!realEdit) | 
| 33 | print(result += " Not editing (test mode)."); | 
| 34 |       else {
 | 
| 35 | editSnippet(#1003674, newText); | 
| 36 | triggerTranspilerDirty(); | 
| 37 | print(result += " Edited #1003674. Now " + countLines(newText) + " lines - " + n2(l(map)+1, "total class", "total classes") + "!"); | 
| 38 | } | 
| 39 |     } else {
 | 
| 40 | print(result = "Class " + name + " already defined as " + def); | 
| 41 | if (sameSnippetID(def, snippetID)) | 
| 42 |         print("Exiting.");
 | 
| 43 | else | 
| 44 |         print("Will not redefine as " + snippetID + ".");
 | 
| 45 | } | 
| 46 | ret result; | 
| 47 | } | 
| 48 | } | 
Began life as a copy of #1003201
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1015881 | 
| Snippet name: | addStdClass - Add a standard class to list (edits #1003674) | 
| Eternal ID of this version: | #1015881/12 | 
| Text MD5: | 94752591b3a2a3b019ccc254aa2de618 | 
| Transpilation MD5: | 7dda6d0211b79c0d03f99fa03acae078 | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2022-01-25 18:09:10 | 
| Source code size: | 1542 bytes / 48 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 672 / 886 | 
| Version history: | 11 change(s) | 
| Referenced in: | [show references] |