Libraryless. Click here for Pure Java version (11242L/62K).
scope replaceKeywordBlock_dyn sinterface #IReplacer { S[] get(LS tok, int iOpening, int iClosing); } static LS replaceKeywordBlock_dyn(S bracket default "{", LS tok, S keyword, IReplacer func) { for (int i = 0; i < 1000; i++) { int idx = findCodeTokens(tok, keyword, bracket); if (idx < 0) break; int j = findEndOfBracketPart(tok, idx+2); S[] be = func?.get(tok, idx+2, j-1); tok.set(idx, unnull(first(be))); tok.set(idx+1, " "); tok.set(idx+2, ""); tok.set(j-1, unnull(second(be))); reTok(tok, idx, j); } ret tok; } end scope
Began life as a copy of #1018806
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1031419 |
| Snippet name: | replaceKeywordBlock_dyn - finally the interface version we all want |
| Eternal ID of this version: | #1031419/10 |
| Text MD5: | b1f297564a54ab21441b7331e37696bd |
| Transpilation MD5: | 507125547f388fe729d20ce29c1ea4f0 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2023-07-26 21:59:38 |
| Source code size: | 607 bytes / 24 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 567 / 837 |
| Version history: | 9 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1031555 - replaceKeywordBlock_dyn_any #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) #1037253 - tok_findFunctionCall |