Hi everybody,
I'm learning the rewrite tool in VW 7.6 and couldn't get clear how to rewrite code recursively. What do I miss? For example for the method someClass#recursiveShow | some temp variables | Transcript show: 'one' , ' two' , ' three' it didn't work to replace ``@rcvr show: ``@object1 , ``@object2 by ``@rcvr show: ``@object1; show: ``@object2 This only found one match and didn't recurse anywhere. Also, searching for | `@temp | didn't find anything in that method ... Any enlightenments are warmly welcome Thomas J. Schrader -- mailto thomas j schrader at web de ________________________________________________________________ Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/ _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hopefully the following example will help you some. Be sure you have the Method checkbox checked when you click the Search or Replace buttons.
myTestClass | myTestMethod | one two three | one := 'one'. two := 'two'. three := 'three'. Transcript show: one , two , three Search For: `methodName | `@temps | `@.setupVariables. Transcript show: `@one, `@two, `@three Replace With: `methodName | `@temps | `@.setupVariables. Transcript show: `@one. Transcript show:`@two. Transcript show: `@three The pieces of the rewrite code that I found confusing at first was the @ sign and statement matching. The @ symbol acts as a wild card for the receiver. Try the following 2 statements and observe how they work differently in your image: `rcvr ifTrue:[`@aTrueBlock] `@rcvr ifTrue:[`@aTrueBlock] Statement matching acts as a wildcard for 0 to many lines of code. The syntax for one line is `.stmt. or spelled out in words <tilde><period><variable name><period>. The syntax for multiples line is `@.stmt. or spelled out in words <tilde><at><period><variable name><period>. I included a statement match for setting up the variables in the example above. `@.setupVariables. will match the 3 lines setting up the 3 temp variables named one, two and three. Hope this helps, Brian -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Thomas Schrader Sent: Monday, August 24, 2009 1:01 PM To: [hidden email] Subject: [vwnc] RewriteCodeTool does not rewrite recursively Hi everybody, I'm learning the rewrite tool in VW 7.6 and couldn't get clear how to rewrite code recursively. What do I miss? For example for the method someClass#recursiveShow | some temp variables | Transcript show: 'one' , ' two' , ' three' it didn't work to replace ``@rcvr show: ``@object1 , ``@object2 by ``@rcvr show: ``@object1; show: ``@object2 This only found one match and didn't recurse anywhere. Also, searching for | `@temp | didn't find anything in that method ... Any enlightenments are warmly welcome Thomas J. Schrader -- mailto thomas j schrader at web de ________________________________________________________________ Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/ _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Thomas Schrader
Thomas Schrader wrote:
> I'm learning the rewrite tool in VW 7.6 and couldn't get clear how to rewrite code recursively. > > What do I miss? For example for the method > > someClass#recursiveShow > > | some temp variables | > Transcript show: 'one' , ' two' , ' three' > > it didn't work to replace > > ``@rcvr show: ``@object1 , ``@object2 > > by > > ``@rcvr show: ``@object1; show: ``@object2 > > This only found one match and didn't recurse anywhere. When you select recurse, it doesn't mean that it recurses into the tree you've replaced. It means that it recurses into the parts of your match expression. In the example above, it will recurse into ``@rcvr=Transcript, ``@object1=('one' , ' two'), and ``@object2=' three'. None of these have any #show: expressions, so nothing else is changed. For your example, you'll need to run your rewrite expression multiple times. Each time you run you will eliminate one #, expression in your #show:. John Brant _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |