Libraryless. Click here for Pure Java version (3755L/21K).
static HashSet<S> allClasses_keywords = lithashset("class", "interface", "enum", "sclass", "sinterface", "record", "srecord", "strecord", "asclass", "concept"); // lists returned are actual CNC (N/C/N/.../C/N) - and connected to // original list // only returns the top level classes static LL<S> allClasses(L<S> tok) { LL<S> l = new ArrayList; int n = tok.size(); HashSet<S> _allClasses_keywords = allClasses_keywords; for (int i = 1; i < n; i += 2) { S t = tok.get(i); if ("{".equals(t)) // skip functions i = findEndOfBlock(tok, i)-1; else if (_allClasses_keywords.contains(t) && (tok_isJavaxMetaCommandLeftOf(tok, i) || !(eqGetOneOf(tok, i-2, ".", "include") && !containsNewLine(tok.get(i-1))))) { int j = i; while (j < n && !tok.get(j).equals("{")) j += 2; j = findEndOfBlock(tok, j)+1; i = leftScanModifiers(tok, i); l.add(subList(tok, i-1, Math.min(n, j))); i = j-2; } } ret l; } static LL<S> allClasses(S text) { ret allClasses(javaTok(text)); }
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1001157 |
Snippet name: | allClasses [works on tokenization, also finds enum and interface and most JavaX constructs] |
Eternal ID of this version: | #1001157/19 |
Text MD5: | 729b47a0cb00159c19728bcef278e120 |
Transpilation MD5: | 6d13407a06b677ff5397465c93e15255 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-21 00:34:46 |
Source code size: | 1090 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 800 / 2551 |
Version history: | 18 change(s) |
Referenced in: | [show references] |