Only first match is located
Describe the bug When searching for a hole in an environment, only the first match will be found, even if multiple passes would detect multiple holes in the context.
Reproducing
the config below locates XYZ(); within brackets and moves it to the end of the brackets.
[XYZtoTheEnd]
match="{
:[before]
XYZ(:[params]);
:[after]
}"
rewrite="{
:[before]
:[after]
XYZ(:[params]);
}"
Expected behavior Given the following method, I would like to find all matches and move them to the end.
public void foo(){
XYZ(a);
XYZ(b);
int a=0, b=3, c=4;
XYZ(a,b,c);
}
My expected result would be
public void foo(){
int a=0, b=3, c=4;
XYZ(a);
XYZ(b);
XYZ(a,b,c);
}
however I end up with the following, because the brackets are no longer inspected once a match is found.
public void foo(){
XYZ(b);
int a=0, b=3, c=4;
XYZ(a,b,c);
XYZ(a);
}
Additional context It seems uncertain to me whether this is a bug or the expected behavior; if it isn't a bug, I'm curious how one would achieve the result I'm looking for. The reason brackets are necessary is that there are multiple methods in the file which need to be arranged in this way, rather than collecting all the matches in one place.
@Nikoraito This gets you a bit closer to what you want. I think the whitespace before and after :[before] isn't getting matched in your example code.
match="""{
:[before]XYZ(:[params]);
:[after]
}"""