1 | /* e.g. |
2 | if (x exists): |
3 | ask (what is x?) |
4 | else: |
5 | ask (does x exist?) |
6 | => a list with two elements |
7 | |
8 | input has to be starting at column 1! (call autoUnindent if unsure) |
9 | */ |
10 | static LS groupPythonStyleIndents_honoringBrackets(S text) { |
11 | LS lines = lines_honoringBrackets(text); |
12 | new LS out; |
13 | int startOfBlock = 0; |
14 | for i over lines: { |
15 | bool indented = startsWithSpace(lines.get(i)); |
16 | if (!indented) { |
17 | addIfNempty(out, lines_rtrim(subList(lines, startOfBlock, i))); |
18 | startOfBlock = i; |
19 | } |
20 | } |
21 | addIfNempty(out, lines_rtrim(subList(lines, startOfBlock))); |
22 | ret out; |
23 | } |
Began life as a copy of #1025586
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025611 |
Snippet name: | groupPythonStyleIndents_honoringBrackets - TODO: unclosed multi-line string literals |
Eternal ID of this version: | #1025611/2 |
Text MD5: | 1d38048d4060665eb963770be8a69de5 |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-08 13:52:17 |
Source code size: | 621 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 255 / 263 |
Version history: | 1 change(s) |
Referenced in: | [show references] |