1 | static String moveImportsUp2(String s) {
|
2 | List<String> l = toLines(s); |
3 | Pattern p = Pattern.compile("^\\s*import\\s");
|
4 | |
5 | // Count import statements on top |
6 | int iStart = 0; |
7 | while (iStart < l(l) && p.matcher(l.get(iStart)).find()) |
8 | ++iStart; |
9 | |
10 | // Find import statements in rest |
11 | L<S> l2 = subList(l, iStart); |
12 | new L<S> x; |
13 | ListIterator<String> i = l2.listIterator(); |
14 | while (i.hasNext()) {
|
15 | S line = i.next(); |
16 | if (p.matcher(line).find()) {
|
17 | x.add(line); |
18 | i.remove(); |
19 | } |
20 | } |
21 | |
22 | // Return null or changed version |
23 | if (isEmpty(x)) ret null; |
24 | return fromLines(concatLists(subList(l, 0, iStart), x, l2)); |
25 | } |
Began life as a copy of #1000608
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1006088 |
| Snippet name: | moveImportsUp2 - returns null if no change, TODO |
| Eternal ID of this version: | #1006088/1 |
| Text MD5: | e478e10b30f6043a137d3feaccd52bf1 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-12-17 15:00:29 |
| Source code size: | 664 bytes / 25 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 731 / 881 |
| Referenced in: | [show references] |