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

24
LINES

< > BotCompany Repo | #1033795 // tok_settableFields backup

JavaX fragment (include)

svoid tok_settableFields(LS tok) {
  int i = -1;
  while ((i = jfind(tok, i+1, "settable <id>")) >= 0) {
    int iEndOfLModifiers = i;
    int iLModifiers = tok_leftScanModifiers(tok, iEndOfLModifiers);
    int iRModifiers = i+2;
    int iEndOfRModifiers = tok_scanModifiers_idx(tok, iRModifiers);
    int iType = iEndOfRModifiers;
    int iEndOfType = tok_endOfType(tok, iEndOfRModifiers);
    S type = joinSubList_cToC(tok, iType, iEndOfType);
    S var = identifierOrQuestionMark(get(tok, iEndOfType);
    LS modifiers = identifiersOnly(joinLists(
      subList(tok, iLModifiers, iEndOfLModifiers),
      subList(tok, iRModifiers, iEndOfRModifiers)));
    LS functionModifiers = listMinus(modifiers, "volatile", "transient");
    printVars(+i, +iRModifiers, +iEndOfRModifiers, +iType, +iEndOfType, +type, +var);
    tokReplace_reTok(tok, iLModifiers, i+2, tok_formatDollarVars(
      joinWithSpace(functionModifiers)
        + "public selfType $var aka $setVar($type $var) { this.$var = $var; this; } gettable ",
      +type, +var, setVar := "set" + firstToUpper(var)));
  }
  
  tok_gettableFields(tok);
}

Author comment

Began life as a copy of #1033078

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1033795
Snippet name: tok_settableFields backup
Eternal ID of this version: #1033795/1
Text MD5: 9445c7861b1975c00272a9ce02b1ea68
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-05 02:53:16
Source code size: 1132 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 125 / 147
Referenced in: