Hi Laura,

you can use the parse tree rewriter of the Refactoring Browser set. Like that, you can have a degree of control about what you do replace and on what.

For example, I'd try something like:

| rewrite |
rewrite := RBParseTreeRewriter new
        replace: 'expression1'
        with: 'expression2'.
myClass methods
        do: [ :e |
                (rewrite executeTree: (RBParser parseMethod: e sourceCode))
                        ifTrue: [ myClass compile: rewrite tree newSource ] ]

I'm not entirely sure it will do what I expect, but I'm trying to learn to use it more than I usually do, because it's very powerfull.

Another example where the rewriter execute some smalltalk code during the search replace:

https://gist.github.com/ThierryGoubier/54ba2fcf3cd2e7db9b1e

Thierry

Le 19/03/2015 17:51, Laura Risani a écrit :
Hi all,

How do you replace all 'expression1' in source code by 'expression2'?
I can find them with Finder but don't see any easy way to replace them.
My problem is i want to change parameter names in many methods.

Best,
Laura


Reply via email to