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

21
LINES

< > BotCompany Repo | #1031283 // tok_cleanImports - drop unused imports from Java code

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

Transpiled version (3795L) is out of date.

static LS tok_cleanImports(LS tok) {
  LS index = toContentsIndexedList(tok);
  L<IntRange> imports = tok_findImports_returnRanges(tok);
  new BitSet exclude;
  for (IntRange r : imports)
    set(exclude, r.end-4);
    
  new L<IntRange> reToks;
  loop: for (IntRange r : imports) {
    S id = get(tok, r.end-4);
    if (!isIdentifier(id)) continue;
    for (int i : indicesOf(index, id))
      if (!get(exclude, i))
        continue loop; // id is in use
    // import is unused - delete
    clearTokens_addToReToks(tok, r.start+1, r.end, reToks);
  }
  
  reTok_multi(tok, reToks);
  ret tok;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031283
Snippet name: tok_cleanImports - drop unused imports from Java code
Eternal ID of this version: #1031283/11
Text MD5: 491666ffd2e3999e1b4095e866ed2287
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-21 18:24:15
Source code size: 616 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 216 / 309
Version history: 10 change(s)
Referenced in: [show references]