void () { final String in = """ class A { void a(int b) {} }"""; final String what = "int '_a = '_b{0,1};"; final String by = "final long /*!*/ $a$ = $b$;"; assertEquals(""" class A { void a(final long /*!*/ b) {} }""", replace(in, what, by)); final String in2 = """ class X { void m() { for (int x : new int[]{1, 2, 3}) {} } }"""; final String what2 = "'_T '_v = '_i{0,1};"; final String by2 = "final $T$ /*!*/ $v$ = $i$;"; assertEquals("foreach parameter replaced incorrectly", """ class X { void m() { for (final int /*!*/ x : new int[]{1, 2, 3}) {} } }""", replace(in2, what2, by2)); }