sS indentStructureString(int levels default 100, S s) { if (s == null) null; LS tok = javaTokForStructure(s); new StringBuilder buf; int indent = 0; levels = clampToInt(levels*2L); for i over tok: { S t = tok.get(i); if (isOpeningBracket(t)) { int j = i+5; if (containsClosingBracket(subList(tok, i+2, i+5))) { buf.append(joinSubList(tok, i, j)); i = j-1; } else { indent += 2; buf.append(t); if (indent <= levels) buf.append("\n").append(spaces(indent)); } } else if (isClosingBracket(t)) { indent -= 2; if (indent < levels) buf.append("\n").append(spaces(indent)); buf.append(t); } else if (indent <= levels && eq(t, ",")) { buf.append(t).append("\n").append(spaces(indent)); i++; } else buf.append(t); } ret str(buf); }
Began life as a copy of #1021424
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1035337 |
| Snippet name: | indentStructureString backup |
| Eternal ID of this version: | #1035337/1 |
| Text MD5: | 7e555da62ed9915b24925aff66548c43 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-05-01 17:56:31 |
| Source code size: | 907 bytes / 32 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 325 / 347 |
| Referenced in: | [show references] |