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

36
LINES

< > BotCompany Repo | #1034677 // findFunctionDefsAtCurlyLevel_indexed [dev.]

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

Libraryless. Click here for Pure Java version (5994L/33K).

1  
static LS findFunctionDefsAtCurlyLevel_indexed(int targetCurlyLevel, IContentsIndexedList2<S> tok) {
2  
  new LS functions;
3  
  new OrderedMultiIterator<HasIndex> multiIterator;
4  
  
5  
  for (keyword : findFunctionDefs_keywords())
6  
    multiIterator.add(tok.indicesOf_treeSetOfHasIndex(keyword));
7  
  multiIterator.add(tok.indicesOf_treeSetOfHasIndex("{"));
8  
  multiIterator.add(tok.indicesOf_treeSetOfHasIndex("}"));
9  
  multiIterator.add(tok.indicesOf_treeSetOfHasIndex("meta"));
10  
  
11  
  int curlyLevel = 0;
12  
  new BitSet ignore;
13  
  while (multiIterator.hasNext()) {
14  
    HasIndex idx = multiIterator.next();
15  
    int i = idx!;
16  
    if (ignore.get(i)) continue;
17  
    S t = tok.get(i);
18  
  
19  
    // Account for meta-for (don't change curly level)
20  
    if (eq(t, "meta")) {
21  
      if (eqSubList(tok, i+1, "", "-", "", "for")) {
22  
        var r = tok_findFirstBlock(tok, i);
23  
        ignore.set(r.start);
24  
        ignore.set(r.end-1);
25  
      }
26  
    } else if (eq(t, "{"))
27  
      ++curlyLevel;
28  
    else if (eq(t, "}"))
29  
      --curlyLevel;
30  
    else // it's a function keyword
31  
      if (curlyLevel == targetCurlyLevel)
32  
        findFunctionDefs_step(tok, i, functions);
33  
  }
34  
  
35  
  ret functions;
36  
}

Author comment

Began life as a copy of #1034500

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034677
Snippet name: findFunctionDefsAtCurlyLevel_indexed [dev.]
Eternal ID of this version: #1034677/4
Text MD5: 5a94bd51a77f12d4737b77f1aa78e775
Transpilation MD5: 86c5aa2069670c4de6131b75ac813c68
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-01 19:53:52
Source code size: 1189 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 168 / 260
Version history: 3 change(s)
Referenced in: [show references]