Libraryless. Click here for Pure Java version (8161L/46K).
1 | scope tok_importedClassNames. |
2 | |
3 | // names that don't fit the uppercase-is-class mantra |
4 | static Map<S, Bool> #specialNames = litmap( |
5 | "_MethodCache" := true, |
6 | "DynamicObject_loading" := false |
7 | ); |
8 | |
9 | static LS tok_importedClassNames(LS tok, IVF2<LS, IntRange> importFound default null) { |
10 | new LS names; |
11 | int n = l(tok); |
12 | for (int i = 1; i < n; i += 2) |
13 | 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; |
14 | int j = findEndOfStatement(tok, i); // index of ;+1 |
15 | S s = get(tok, j-3); |
16 | |
17 | // This is to distinguish from imported functions; |
18 | // yes it's rough. |
19 | if (or(specialNames.get(s), isIdentifier(s) && startsWithUpperCase(s))) |
20 | names.add(s); |
21 | |
22 | if (importFound != null) { |
23 | // We assume importFound can change the import statement and also reTok it |
24 | importFound.get(tok, intRange(i, j)); |
25 | n = l(tok); |
26 | } else |
27 | i = j-1; |
28 | } |
29 | ret names; |
30 | } |
31 | |
32 | end scope |
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: | 720 / 1238 |
Version history: | 14 change(s) |
Referenced in: | [show references] |