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

19
LINES

< > BotCompany Repo | #1034464 // Tok_SimpleSizeAnalysis

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

Transpiled version (6166L) is out of date.

1  
srecord noeq Tok_SimpleSizeAnalysis(LS tok) {
2  
  new LS lines;
3  
  
4  
  S get() {
5  
    scan(tok, 1);
6  
    ret lines(sortedDesc(lines));
7  
  }
8  
  
9  
  void scan(LS tok, int level) {
10  
    for (IntRange r : tok_allCurlyBodies(tok)) {
11  
      int iLineStart = tok_beginningOfLine(tok, r.start);
12  
      int tokens = countTokens(r);
13  
      lines.add(lpad(14, nTokens(tokens)) + " (level " + level + "): " 
14  
        + shorten(trimJoinSubList(tok, iLineStart, r.start-1)));
15  
    
16  
      scan(tokSubList(tok, intRange(r.start+2, r.end)), level+1);
17  
    }
18  
  }
19  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034464
Snippet name: Tok_SimpleSizeAnalysis
Eternal ID of this version: #1034464/7
Text MD5: fa95cb4147aea80de7c5ba20311f8199
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-08 01:41:51
Source code size: 548 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 136 / 235
Version history: 6 change(s)
Referenced in: [show references]