Libraryless. Click here for Pure Java version (1576L/11K/37K).
!759 p { S java = loadTextFile(getProgramFile("#1005014", "mochadoom.java")); L<S> tok = javaTok(java); L<Int> indexes = jfindAll(tok, "package"); if (empty(indexes) || indexes.get(0) != 1) indexes.add(0, 1); for i over indexes: { int from = indexes.get(i); int to = i+1 < l(indexes) ? indexes.get(i+1) : l(tok); L<S> subtok = cncSubList(tok, from, to); S src = join(subtok); //print(shorten(src, 80)); S pack = tok_packageName(subtok); print("Package: " + quote(pack)); L<L<S>> classes = allClasses(subtok); for (L<S> c : classes) { //print(" Class: " + shorten(join(c), 80)); print(" Class: " + quote(getClassDeclarationName(c))); } if (empty(classes)) print("No classes?? " + quote(src)); else if (l(classes) == 1) { S fileName = addSlash(pack.replace('.', '/')) + getClassDeclarationName(first(classes)) + ".java"; print("File name: " + fileName); } else fail("Not supported"); print(); // TODO saveTextFile(getProgramFile("src", sourceName)); } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005018 |
Snippet name: | Split single source into .java files [WORKS for simple cases, e.g. "Mocha Doom"] |
Eternal ID of this version: | #1005018/1 |
Text MD5: | ceafb741b48eb46aec5da58f402b14bc |
Transpilation MD5: | 27505f63467dda5b480957928495d8ac |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-09-28 21:49:22 |
Source code size: | 1097 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 584 / 709 |
Referenced in: | [show references] |