1 | static bool allVarNames_debug; |
2 | |
3 | static L<S> allVarNames(L<S> tok) {
|
4 | bool debug = allVarNames_debug; |
5 | Map<Int, Int> bracketMap = getBracketMap(tok); |
6 | new L<S> varNames; |
7 | for (int i = 3; i < tok.size(); i += 2) {
|
8 | S t = tok.get(i); |
9 | if (eqOneOf(t, "=", ";", ",")) {
|
10 | S v = tok.get(i-2); |
11 | if (isIdentifier(v)) |
12 | varNames.add(v); |
13 | if (eq(t, "=")) {
|
14 | i = scanToEndOfInitializer(tok, bracketMap, i)+1; |
15 | assertTrue(odd(i)); |
16 | } |
17 | } else if (eq(t, "<")) {
|
18 | i = findEndOfTypeArgs(tok, i)+1; |
19 | if (debug) |
20 | print("Skipped type args: " + struct(subList(tok, i)));
|
21 | } else if (eqOneOf(t, "{", "("))
|
22 | i = findEndOfBracketPart(tok, i)-1; // skip function/class bodies |
23 | } |
24 | return varNames; |
25 | } |
26 | |
27 | static L<S> allVarNames(S text) {
|
28 | ret allVarNames(javaTok(text)); |
29 | } |
Began life as a copy of #1001157
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: | #1005504 |
| Snippet name: | allVarNames - find all variable/field declarations in a block/class |
| Eternal ID of this version: | #1005504/5 |
| Text MD5: | 36a512fb2957bd9031b1f9bf45ef3488 |
| Author: | stefan |
| Category: | javax / parsing |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-12-14 01:41:40 |
| Source code size: | 852 bytes / 29 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 787 / 1036 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |