1 | static S replaceOrDropCodeTokensUsingMap(S s, SS map) { |
2 | ret join(replaceOrDropCodeTokensUsingMap(javaTok(s), map); |
3 | } |
4 | |
5 | static LS replaceOrDropCodeTokensUsingMap(LS tok, SS map) { |
6 | LS out = emptyList(tok); |
7 | for i over tok: { |
8 | if (odd(i)) out.add(tok.get(i)); |
9 | else { |
10 | S val = lookupOrKeep(map, tok.get(i)); |
11 | if (nempty(val)) |
12 | out.add(val); |
13 | else { |
14 | out.add(ai_mergeWhitespace(last(out), tok.get(i+1))); |
15 | i++; |
16 | } |
17 | } |
18 | } |
19 | ret out; |
20 | } |
21 | |
22 | sS replaceOrDropCodeTokensUsingMap(SS map, S s) { |
23 | ret replaceOrDropCodeTokensUsingMap(s, map); |
24 | } |
Began life as a copy of #1014558
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023231 |
Snippet name: | replaceOrDropCodeTokensUsingMap - drops token on empty value [dev.] |
Eternal ID of this version: | #1023231/3 |
Text MD5: | 081792eea64aba59023a3b81a2e4e2f3 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-05-18 13:42:38 |
Source code size: | 606 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 246 / 276 |
Version history: | 2 change(s) |
Referenced in: | [show references] |