static S jreplace_first_dyn(S s, S in, O out) { ret jreplace_first_dyn(s, in, out, null); } static S jreplace_first_dyn(S s, S in, O out, O condition) { L tok = javaTok(s); ret jreplace_first_dyn(tok, in, out, false, false, condition) ? join(tok) : s; } // leaves tok properly tokenized // returns true iff anything was replaced static boolean jreplace_first_dyn(L tok, S in, O out) { ret jreplace_first_dyn(tok, in, out, false, true, null); } static boolean jreplace_first_dyn(L tok, S in, O out, O condition) { ret jreplace_first_dyn(tok, in, out, false, true, condition); } static boolean jreplace_first_dyn(L tok, S in, O out, boolean ignoreCase, boolean reTok, O condition) { L tokin = javaTok(in); jfind_preprocess(tokin); boolean anyChange = false; int i = 1; if ((i = findCodeTokens(tok, i, ignoreCase, toStringArray(codeTokensOnly(tokin)), condition)) >= 0) { L subList = tok.subList(i-1, i+l(tokin)-1); // N to N S expansion = cast callF(out, tok, i); int end = i+l(tokin)-2; clearAllTokens(tok, i, end); // C to C tok.set(i, expansion); if (reTok) reTok(tok, i, end); anyChange = true; } ret anyChange; }