void () { String in1 = """ class A { void b(int c, int d, /*1*/ int e) {} }"""; String expected1a = """ class A { void b(int c, int d2, /*1*/ int e) {} }"""; assertEquals("replace method parameter", expected1a, replace(in1, "int d;", "int d2;")); String expected1b = """ class A { void b(int /*!*/ c, int /*!*/ d, /*1*/ int /*!*/ e) {} }"""; assertEquals(expected1b, replace(in1, "void b('_T '_v*);", "void b($T$ /*!*/ $v$);")); String expected1c = """ class A { void /**/ b(int c, int d, /*1*/ int e) {} }"""; assertEquals("replace multi match parameter", expected1c, replace(in1, "void b(int '_x*);", "void /**/ b(int $x$);")); String expected1d = """ class A { void b(int c, int d, /*1*/ int e) {} void c(int c, int d, /*1*/ int e) {} }"""; assertEquals("replace multiple occurrences of the same variable", expected1d, replace(in1, "void b('_T '_p*);", "void b($T$ $p$);\n" + "void c($T$ $p$) {}")); String in2 = """ class X { void x() {} }"""; String expected2 = """ class X { void /**/ x() {} }"""; assertEquals("replace no match parameter", expected2, replace(in2, "void x(int '_a*);", "void /**/ x() {}")); String in3 = """ class X { void x(String s, Integer i) {} }"""; String expected3 = """ class X { void x(List<String> /*>*/ s, List<Integer> /*>*/ i) {} }"""; assertEquals(expected3, replace(in3, "void x('_T '_v*);", "void x(List<$T$> /*>*/ $v$);")); String in4 = """ class X { void a(Map<String, Integer> b, Map<String, Integer> c) {} }"""; String expected4 = "class X {\n" + " void a(Map<String, Integer> /*!*/ b, Map<, > /*!*/ c) {}\n" + // todo fix replacement of second parameter type "}"; assertEquals(expected4, replace(in4, "void a('_T<'_K, '_V> '_p*);", "void a($T$<$K$, $V$> /*!*/ $p$);")); }