static new ThreadLocal tok_typesAndNamesOfParams_keepModifiers; static LPairS tok_typesAndNamesOfParams(L tok, O... _) { bool keepModifiers = boolPar(tok_typesAndNamesOfParams_keepModifiers); optPar bool typelessMeansObject; try { new L> out; for (int i = 1; i < l(tok); ) { i = tok_skipAnnotations(tok, i); S t = get(tok, i); S pre = ""; ifdef tok_typesAndNamesOfParams_debug print("t=" + t + ", next=" + get(tok, i+2)); endifdef // yeah, the typeless handling is a mess... if (typelessMeansObject && isIdentifier(t) && eqGetOneOf(tok, i+2, ",", null)) { i += 4; continue with out.add(pair("Object", t)); } if (eqOneOf(t, "final", "transient")) { if (keepModifiers) pre += t + " "; t = get(tok, i += 2); } if (eq(t, "virtual")) { pre += "virtual "; t = get(tok, i += 2); } if (eq(t, "new")) { pre += "new "; t = get(tok, i += 2); } assertTrue(isIdentifier(t)); i += 2; S type = t, name = "?"; while (eq(get(tok, i), ".") && !eqGet(tok, i+2, ".")) { type += "." + assertIdentifier(get(tok, i+2)); i += 4; } // just a parameter name, no type if (eqOneOf(get(tok, i), null, ",")) { name = type; type = "?"; } else { if (eq(tok.get(i), "<")) { int j = findEndOfTypeArgs(tok, i)-1; while (eq(get(tok, j), "[") && eq(get(tok, j+2), "]")) j += 4; type += trimJoinSubList(tok, i, j+1); S id = assertIdentifier(tok.get(j+2)); i = j+2; } while (eq(get(tok, i), "[") && eq(get(tok, i+2), "]")) { i += 4; type += "[]"; } if (eqGet(tok, i, "etc")) { i += 2; type += " etc"; } if (eqGet(tok, i, ".") && eqGet(tok, i+2, ".") && eqGet(tok, i+4, ".")) { type += "..."; i += 6; } name = assertIdentifier(tok.get(i)); i += 2; while (eq(get(tok, i), "[") && eq(get(tok, i+2), "]")) { i += 4; type += "[]"; } // skip default value if (eqGet(tok, i, "default")) i = tok_findEndOfExpression(tok, i+2)+1; if (i < l(tok)) { assertEquals(get(tok, i), ","); i += 2; } } out.add(pair(pre + type, name)); } ret out; } catch e { print("Bad parameter declaration: " + sfu(tok)); throw rethrow(e); } }