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

32
LINES

< > BotCompany Repo | #1004092 // tok_importedClassNames (just the names, not the packages)

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

Libraryless. Click here for Pure Java version (8161L/46K).

scope tok_importedClassNames.

// names that don't fit the uppercase-is-class mantra
static Map<S, Bool> #specialNames = litmap(
  "_MethodCache" := true,
  "DynamicObject_loading" := false
);

static LS tok_importedClassNames(LS tok, IVF2<LS, IntRange> importFound default null) {
  new LS names;
  int n = l(tok);
  for (int i = 1; i < n; i += 2)
    if (eq(tok.get(i), "import") /*&& neq(get(tok, i+2), "static")*/) { // static may be OK, e.g. import static x30_pkg.x30_util.VF1;
      int j = findEndOfStatement(tok, i); // index of ;+1
      S s = get(tok, j-3);
      
      // This is to distinguish from imported functions;
      // yes it's rough.
      if (or(specialNames.get(s), isIdentifier(s) && startsWithUpperCase(s)))
        names.add(s);
        
      if (importFound != null) {
        // We assume importFound can change the import statement and also reTok it
        importFound.get(tok, intRange(i, j));
        n = l(tok);
      } else
        i = j-1;
    }
  ret names;
}

end scope

Author comment

Began life as a copy of #1003837

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004092
Snippet name: tok_importedClassNames (just the names, not the packages)
Eternal ID of this version: #1004092/15
Text MD5: e48758ab02dd9b37dd2a81033fad90ca
Transpilation MD5: e7536bf94aec82a986acf7f6721173d5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-28 16:16:09
Source code size: 1040 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 576 / 1050
Version history: 14 change(s)
Referenced in: [show references]