Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1024308 // tlftj_honoringBrackets - like tlfj, but keeps bracket-enclosed lines together

JavaX fragment (include)

1  
static LS tlftj_honoringBrackets(S s) {
2  
  LS tok = javaTokWithBrackets(javaDropComments(s));
3  
  new LS out;
4  
  int j = 1;
5  
  for (int i = 2; i+1 < l(tok); i += 2)
6  
    if (containsNewLine(tok.get(i))) {
7  
      addIfNempty(out, joinSubList(tok, j, i));
8  
      j = i+1;
9  
    }
10  
  if (j < l(tok)-1)
11  
    addIfNempty(out, joinSubList(tok, j, l(tok)-1));
12  
  ret out;
13  
}

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: #1024308
Snippet name: tlftj_honoringBrackets - like tlfj, but keeps bracket-enclosed lines together
Eternal ID of this version: #1024308/7
Text MD5: 5993b2f65d62c60567d9f9513b5952d6
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-31 01:32:37
Source code size: 365 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 274 / 313
Version history: 6 change(s)
Referenced in: [show references]