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

18
LINES

< > BotCompany Repo | #1021796 // tok_equalsCast

JavaX fragment (include)

static LS tok_equalsCast(LS tok) {
  if (!tok.contains("cast")) ret tok;
  int iVar = -1;
  while ((iVar = jfind(tok, iVar+1, "<id> = cast")) >= 0) {
    int iTypeStart = tok_scanTypeBackwards(tok, iVar-2);
    int iCast = iVar+4;
    int j = scanToEndOfInitializer2(tok, iCast);
    S type = joinSubList(tok, iTypeStart, iVar-1);
    clearTokens(tok, iCast, iCast+1);
    if (!tok_typeIsObject(type)) {
      bool needBrackets = j > iCast+4;
      tokPrepend(tok, iCast+2, "(" + type + ") " + (needBrackets ? "(" : ""));
      if (needBrackets) tokPrepend(tok, j+1, ")");
    }
    reTok(tok, iCast, j+2);
  }
  ret tok;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021796
Snippet name: tok_equalsCast
Eternal ID of this version: #1021796/20
Text MD5: 7479e2476eb5fb2e08cb288fd878abb8
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-29 00:17:40
Source code size: 640 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 367 / 395
Version history: 19 change(s)
Referenced in: [show references]