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

37
LINES

< > BotCompany Repo | #1034877 // tok_javaCallsToLeftArrowStyle

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

Transpiled version (5184L) is out of date.

// doesn't reTok
static LS tok_javaCallsToLeftArrowStyle(LS tok, int recursionLevel default 0) {
  bigLoop: for (int i = 1; i < l(tok); i += 2) {
    printVars ifdef tok_javaCallsToLeftArrowStyle_debug(+i, n := l(tok), +recursionLevel);
    if (isIdentifier(tok.get(i)) && eqGet(tok, i+2, "(")) {
      // move opening bracket in front of function name
      tokPrepend(tok, i, "(");
      
      // replace opening bracket with space
      replaceTokenWithSpace(tok, i+2);
      
      int iArg = i+4;
      while true {
        int iArgEnd = tok_endOfExpression(tok, iArg)+1;
        i = iArgEnd;
        
        LS argTok = subList(tok, iArg-1, iArgEnd);
        printVars ifdef tok_javaCallsToLeftArrowStyle_debug(+iArg, +iArgEnd, +argTok, +recursionLevel);
        
        // recurse for argument
        tok_javaCallsToLeftArrowStyle(argTok, recursionLevel+1);
        
        if (!eqGet(tok, iArgEnd, ","))
          break;
        else {
          // replace comma with space
          replaceTokenWithSpace(tok, iArgEnd);

          iArg = iArgEnd+2;
        }
      }
      
      continue bigLoop;
    }
  }
  ret tok;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034877
Snippet name: tok_javaCallsToLeftArrowStyle
Eternal ID of this version: #1034877/12
Text MD5: 2b12f04f1f7c20bc00b359c3da3ee846
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-13 00:00:19
Source code size: 1170 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 251
Version history: 11 change(s)
Referenced in: [show references]