static bool allVarNamesWithTypes_debug; // TODO: array brackets static SS allVarNamesWithTypes(L tok) { bool debug = allVarNamesWithTypes_debug; Map bracketMap = getBracketMap(tok); SS vars = litorderedmap(); int i = 1; while (i < l(tok)) { while (isJavaModifier(tok.get(i))) i += 2; ... 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 (eq(t, "{")) i = findEndOfBlock(tok, i)+1; // skip function/class bodies } return vars; } static SS allVarNamesWithTypes(S text) { ret allVarNamesWithTypes(javaTok(text)); }