1 | static S jreplace_first(S s, S in, S out) { |
2 | ret jreplace_first(s, in, out, null); |
3 | } |
4 | |
5 | static S jreplace_first(S s, S in, S out, O condition) { |
6 | L<S> tok = javaTok(s); |
7 | ret jreplace_first(tok, in, out, false, false, condition) ? join(tok) : s; |
8 | } |
9 | |
10 | // leaves tok properly tokenized |
11 | // returns true iff anything was replaced |
12 | static boolean jreplace_first(L<S> tok, S in, S out) { |
13 | ret jreplace_first(tok, in, out, false, true, null); |
14 | } |
15 | |
16 | static boolean jreplace_first(L<S> tok, S in, S out, O condition) { |
17 | ret jreplace_first(tok, in, out, false, true, condition); |
18 | } |
19 | |
20 | static boolean jreplace_first(L<S> tok, S in, S out, boolean ignoreCase, boolean reTok, O condition) { |
21 | L<S> tokin = javaTok(in); |
22 | jfind_preprocess(tokin); |
23 | |
24 | boolean anyChange = false; |
25 | int i = 1; |
26 | if ((i = findCodeTokens(tok, i, ignoreCase, toStringArray(codeTokensOnly(tokin)), condition)) >= 0) { |
27 | L<S> subList = tok.subList(i-1, i+l(tokin)-1); // N to N |
28 | S expansion = jreplaceExpandRefs(out, subList); |
29 | int end = i+l(tokin)-2; |
30 | clearAllTokens(tok, i, end); // C to C |
31 | tok.set(i, expansion); |
32 | if (reTok) |
33 | reTok(tok, i, end); |
34 | anyChange = true; |
35 | } |
36 | ret anyChange; |
37 | } |
38 | |
39 | static bool jreplace_first_debug; |
Began life as a copy of #1004948
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019424 |
Snippet name: | jreplace_first - replace only once |
Eternal ID of this version: | #1019424/1 |
Text MD5: | 0afcd7c4c8ead0f7e453751f89b15df1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-06 18:06:15 |
Source code size: | 1242 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 335 / 363 |
Referenced in: | [show references] |