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).

sS tok_insertAFewSpaces(S s) {
  ret join(tok_insertAFewSpaces(javaTok(s)));
}

static LS tok_insertAFewSpaces(LS tok) {
  int n = l(tok);
  for (int i = 1; i+2 < n; i += 2) {
    if (eqGet(tok, i+1, "")) {
      S me = get(tok, i), next = get(tok, i+2);
      if (eq(me, "}") && (isIdentifier(next) || eq(next, "("))
        || eq(me, ")") && eq(next, "{"))
        tok.set(i+1, " ");
    }
  }
  ret tok;
}

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: 96 / 136
Version history: 6 change(s)
Referenced in: [show references]