static void splitJavaFiles(L<S> tok) ctex { splitJavaFiles(tok, newFile("output")); } static void splitJavaFiles(L<S> tok, File outDir) ctex { L<Int> indexes = jfindAll(tok, "package"); if (empty(indexes) || indexes.get(0) != 1) indexes.add(0, 1); for (int i = 0; i < l(indexes); i++) { 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 { S className = getNameOfPublicClass(subtok); if (className == null) className = getNameOfAnyClass(subtok); S fileName = addSlash(pack.replace('.', '/')) + className + ".java"; print("File name: " + fileName); saveTextFile(newFile(outDir, fileName), join(subtok)); } print(); } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005025 |
Snippet name: | splitJavaFiles - split a joined source into .java files |
Eternal ID of this version: | #1005025/5 |
Text MD5: | 33dce6d0d9dcdf87c0ec1ecef7c3ca07 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-24 14:01:28 |
Source code size: | 1191 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 548 / 865 |
Version history: | 4 change(s) |
Referenced in: | [show references] |