static bool allVarNames_debug; static L allVarNames(L tok) { bool debug = allVarNames_debug; Map bracketMap = getBracketMap(tok); new L varNames; for (int i = 3; i < tok.size(); i += 2) { S t = tok.get(i); if (eqOneOf(t, "=", ";", ",")) { S v = tok.get(i-2); if (isIdentifier(v)) varNames.add(v); if (eq(t, "=")) { i = scanToEndOfInitializer(tok, bracketMap, i)+1; assertTrue(odd(i)); } } else if (eq(t, "<")) { i = findEndOfTypeArgs(tok, i)+1; if (debug) print("Skipped type args: " + struct(subList(tok, i))); } else if (eqOneOf(t, "{", "(")) i = findEndOfBracketPart(tok, i)-1; // skip function/class bodies } return varNames; } static L allVarNames(S text) { ret allVarNames(javaTok(text)); }