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

16
LINES

< > BotCompany Repo | #1032274 // tok_insertAFewSpaces

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4091L/24K).

1  
sS tok_insertAFewSpaces(S s) {
2  
  ret join(tok_insertAFewSpaces(javaTok(s)));
3  
}
4  
5  
static LS tok_insertAFewSpaces(LS tok) {
6  
  int n = l(tok);
7  
  for (int i = 1; i+2 < n; i += 2) {
8  
    if (eqGet(tok, i+1, "")) {
9  
      S me = get(tok, i), next = get(tok, i+2);
10  
      if (eq(me, "}") && (isIdentifier(next) || eq(next, "("))
11  
        || eq(me, ")") && eq(next, "{"))
12  
        tok.set(i+1, " ");
13  
    }
14  
  }
15  
  ret tok;
16  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032274
Snippet name: tok_insertAFewSpaces
Eternal ID of this version: #1032274/7
Text MD5: 027d7a81b5fd6b57a2373ccd01815eeb
Transpilation MD5: 4493440653f2bfdd2c45aecf1b2b0103
Author: stefan
Category: javax / transpilation
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-11 10:17:17
Source code size: 423 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 210
Version history: 6 change(s)
Referenced in: [show references]