Libraryless. Click here for Pure Java version (4828L/27K).
static S migrateClassesInStructureText(S s, O... migrations) { L<S> tok = javaTokForStructure(s); int n = l(tok); for (int i = 0; i < l(migrations); i += 2) { S from = cast migrations[i]; S fromPlusDollar = from + "$"; O to = migrations[i+1]; S replacement = to instanceof S ? (S) to : dropPrefix("main$", className((Class) to); int changes = 0; for (int j = 1; j < n; j += 2) { S t = tok.get(j); if (eq(t, from)) { tok.set(j, replacement); ++changes; } else if (startsWith(t, fromPlusDollar)) { tok.set(j, replacement + t.substring(l(from))); ++changes; } } if (changes > 0) print("migrateClassesInStructureText: Replaced " + n2(changes, "occurrence") + " of " + from + " with " + to); } ret join(tok); } sS migrateClassesInStructureText(S s, MapSO migrations) { ret migrateClassesInStructureText(s, mapToParams(migrations)); }
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: | #1009477 |
Snippet name: | migrateClassesInStructureText |
Eternal ID of this version: | #1009477/13 |
Text MD5: | 3fa0752bca9262d69c81bf74e5265d9d |
Transpilation MD5: | 25292fb4c7df976dd71442395b490558 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-19 17:01:04 |
Source code size: | 974 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 610 / 712 |
Version history: | 12 change(s) |
Referenced in: | [show references] |