1 | static void splitJavaFiles(L<S> tok) ctex { |
2 | splitJavaFiles(tok, newFile("output")); |
3 | } |
4 | |
5 | static void splitJavaFiles(L<S> tok, File outDir) ctex { |
6 | L<Int> indexes = jfindAll(tok, "package"); |
7 | if (empty(indexes) || indexes.get(0) != 1) |
8 | indexes.add(0, 1); |
9 | for (int i = 0; i < l(indexes); i++) { |
10 | int from = indexes.get(i); |
11 | int to = i+1 < l(indexes) ? indexes.get(i+1) : l(tok); |
12 | L<S> subtok = cncSubList(tok, from, to); |
13 | S src = join(subtok); |
14 | //print(shorten(src, 80)); |
15 | S pack = tok_packageName(subtok); |
16 | print("Package: " + quote(pack)); |
17 | L<L<S>> classes = allClasses(subtok); |
18 | /*for (L<S> c : classes) { |
19 | //print(" Class: " + shorten(join(c), 80)); |
20 | print(" Class: " + quote(getClassDeclarationName(c))); |
21 | }*/ |
22 | if (empty(classes)) |
23 | print("No classes?? " + quote(src)); |
24 | else { |
25 | S className = getNameOfPublicClass(subtok); |
26 | if (className == null) className = getNameOfAnyClass(subtok); |
27 | |
28 | S fileName = addSlash(pack.replace('.', '/')) + className + ".java"; |
29 | print("File name: " + fileName); |
30 | saveTextFile(newFile(outDir, fileName), join(subtok)); |
31 | } |
32 | print(); |
33 | } |
34 | } |
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: | 550 / 867 |
Version history: | 4 change(s) |
Referenced in: | [show references] |