static S migrateClassesInStructureText(S s, O... migrations) { L tok = javaTokForStructure(s); int n = l(tok); for (int i = 0; i < l(migrations); i += 2) { S from = cast migrations[i]; S fromPlusDollar = from + "$"; O to = migrations[i+1]; S replacement = to instanceof S ? (S) to : dropPrefix("main$", className((Class) to); int changes = 0; for (int j = 1; j < n; j += 2) { S t = tok.get(j); if (eq(t, from)) { tok.set(j, replacement); ++changes; } else if (startsWith(t, fromPlusDollar)) { tok.set(j, replacement + t.substring(l(from))); ++changes; } } if (changes > 0) print("migrateClassesInStructureText: Replaced " + n2(changes, "occurrence") + " of " + from + " with " + to); } ret join(tok); } sS migrateClassesInStructureText(S s, MapSO migrations) { ret migrateClassesInStructureText(s, mapToParams(migrations)); }