Login  Register

How to write a simple Code Rewrite for x -> self x?

Posted by Tim M on Mar 23, 2006; 3:22pm
URL: https://forum.world.st/How-to-write-a-simple-Code-Rewrite-for-x-self-x-tp3377980.html

I am stumped on how to use the code rewriter - I've read some of John
and Don's tutorials but I can't get simple stuff to work?

e.g. if I have the method:

executeSomethingElse
        self
                show: 'owner = ' , owner;
                cr;
                show: 'child = ' , child

And I want all direct references to instance vars to be "self ivar" I
thought I could write:

`var

and in the replace pane

self var


The result I get is:

executeSomethingElse
        (self var)
                show: 'owner = ' , self var;
                cr;
                show: 'child = ' , self var



So I'm wondering - after "var" has matched a variable, how I can
reference it in the replace pane?

I also hadn't anticpated getting a match on the initial "self"
reference - this seems to make things more complicated as I have to
filter out variables named "self".

Anyone have any tips on using the Code Rewriter?

Tim