static S jreplace1(S s, S in, S out) { ret jreplace1(s, in, out, null); } static S jreplace1(S s, S in, S out, O condition) { L tok = javaTok(s); ret jreplace1(tok, in, out, condition) ? join(tok) : s; } // leaves tok properly tokenized // returns true iff anything was replaced static boolean jreplace1(L tok, S in, S out) { ret jreplace1(tok, in, out, false, true, null); } static boolean jreplace1(L tok, S in, S out, O condition) { ret jreplace1(tok, in, out, false, true, condition); } static boolean jreplace1(L tok, S in, S out, boolean ignoreCase, boolean reTok, O condition) { L tokin = javaTok(in); jfind_preprocess(tokin); boolean anyChange = false; int i = 1; while ((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 = jreplaceExpandRefs(out, subList); int end = i+l(tokin)-2; clearAllTokens(tok, i, end); // C to C tok.set(i, expansion); int l = l(tok); if (reTok) // would this ever be false?? reTok(tok, i, end); i = end+l(tok)-l; anyChange = true; } ret anyChange; } static bool jreplace1_debug;