void () { String in = """ public abstract class Bar { String[] x; abstract String[] foo(String[] x); }"""; assertEquals("should keep array brackets 1", """ public abstract class Bar { String[] x; abstract String[] foo(String[] x); }""", replace(in, "'_FieldType 'Field = '_Init?;", "$FieldType$ $Field$ = $Init$;", true)); assertEquals("should keep array brackets 2", """ public abstract class Bar { String[] x; abstract String[] foo (String[] x); }""", replace(in, "'_ReturnType '_Method('_ParameterType '_Parameter*);", "$ReturnType$ $Method$ ($ParameterType$ $Parameter$);", true)); String in2 = """ class X { public final X[] EMPTY_ARRAY = {}; }"""; assertEquals("shouldn't delete semicolon", """ class X { public final X[] EMPTY_ARRAY = {}; }""", replace(in2, "'_FieldType 'Field = '_Init?;", "$FieldType$ $Field$ = $Init$;", true)); String in3 = """ class X { void x(int... ss) {} void y() { x(new int[] {1, 2});\s } } """; assertEquals("Should keep commas", """ class X { void x(int... ss) {} void y() { x(1, 2);\s } } """, replace(in3, "new int[] {'_a*}", "$a$", true)); assertEquals("Should keep commas 2", """ class X { void x(int... ss) {} void y() { x(new long[] {1, 2});\s } } """, replace(in3, "new int[] {'_a*}", "new long[] {$a$}")); }