Libraryless. Click here for Pure Java version (2900L/17K).
sS indentStructureString_firstLevels(int levelsToIndent, S s) { if (s == null) null; LS tok = javaTokForStructure(s); new StringBuilder buf; int level = 0; 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 { buf.append(t); ++level; if (level <= levelsToIndent) buf.append("\n").append(spaces(level*2)); } } else if (isClosingBracket(t)) { if (level-- <= levelsToIndent) buf.append("\n").append(spaces(level*2)); buf.append(t); } else if (eq(t, ",")) { buf.append(t); if (level <= levelsToIndent) buf.append("\n").append(spaces(level*2)); 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 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030721 |
Snippet name: | indentStructureString_firstLevels [OK] |
Eternal ID of this version: | #1030721/5 |
Text MD5: | 7900f8e0c16af903d54f76c20f900407 |
Transpilation MD5: | 75519b16f3a11a482c12c327f7c00cdd |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-03-16 18:57:46 |
Source code size: | 905 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 186 / 271 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |