static LS findFunctionDefsAtCurlyLevel(int curlyLevel, S s) { ret findFunctionDefsAtCurlyLevel(curlyLevel, javaTok(s)); } static LS findFunctionDefsAtCurlyLevel(int targetCurlyLevel, LS tok) { new LS functions; var keywords = findFunctionDefs_keywords(); int n = l(tok); int curlyLevel = 0; for (int i = 1; i < n; i += 2) { S t = tok.get(i); curlyLevel += curlyLevel(t); if (curlyLevel == targetCurlyLevel) if (keywords.contains(t)) findFunctionDefs_step(tok, i, functions); } ret functions; }