I'm working on making a change to a large C++ codebase where I need to change a method call to an equivalent function call, e.g. someExpression.foo() becomes bar(someExpression).
A few more examples of the sort of transformation I'm looking for:
(itemA + itemB).foo()becomesbar(itemA + itemB)outerFunction(object->method(), arg2 + val, innerFunction(arg3)).foo()becomesbar(outerFunction(object->method(), arg2 + val, innerFunction(arg3)))
Basically, the expression proceeding the method call to foo() could be fairly complex. But foo() comes up a lot of times in my codebase, so I'm really hoping there's some way I can automate this change rather than having to laboriously edit everything manually.
Can this be done with a regex? Or is there another tool I can use to make this change?