Thanks Hernan.
I love your attitude:
���� - packaging and sharing

Keep pushing

Stef


Le 9/12/15 07:03, Hern��n Morales Durand a ��crit��:
http://www.smalltalkhub.com/#!/~hernan/ProgressBarInstaller

Public write access

Cheers,

Hern��n


2015-12-08 20:40 GMT-03:00 Hern��n Morales Durand <hernan.morales@gmail.com>:
Hi John,

Thank you for your feedback and help!

I started a ProgressBarInstaller using your corrections. Unfortunately SmalltalkHub is not working for me right now but will check tomorrow and share the link.

Best regards,

Hern��n


2015-12-08 13:56 GMT-03:00 John Brant <brant@refactoryworkers.com>:
On 12/7/2015 5:27 PM, Hern��n Morales Durand wrote:

but now I am failing to see how to replace #collect: with
#collect:thenDo: using the rewriter:

http://ws.stfx.eu/MOWS947F000O

You don't need to first search using the RBParseTreeSearcher. The RBParseTreeRewriter works with search patterns. What your code is really doing is searching for the literal pattern that it found from the RBParseTreeSearcher in the FooClass>>foo: method:

aString asFileReference entries
�� �� �� �� collect: [ : fileEntry | self openOnFileNamed: fileEntry fullName ]

It then tries to replace it with the pattern:

`@collection collect: `@arg1
�� �� �� �� thenDo: [ : fileEntry |
�� �� �� �� �� �� �� �� index := index + 1.
�� �� �� �� �� �� �� �� JobProgress progress: (0.1 * index);
�� �� �� �� �� �� �� �� �� �� �� �� title: 'Procesing...', index asString ]

However, since neither `@collection nor `@arg1 appear in your search pattern, you get an error.

Here's a version that works:

�� �� �� �� | cm rewriteRule replacement |
�� �� �� �� cm := FooClass >> #foo:.
�� �� �� �� replacement := '`@collection collect: `@arg1
�� �� �� �� �� �� �� �� thenDo: [ : fileEntry |
�� �� �� �� �� �� �� �� �� �� �� �� index := index + 1.
�� �� �� �� �� �� �� �� �� �� �� �� JobProgress progress: (0.1 * index);
�� �� �� �� �� �� �� �� �� �� �� �� �� �� title: ''Procesing...'', index asString ]'.
�� �� �� �� rewriteRule := RBParseTreeRewriter new
�� �� �� �� �� �� �� �� replace: '`@collection collect: `@arg1'
�� �� �� �� �� �� �� �� with: replacement.
�� �� �� �� rewriteRule executeTree: cm parseTree.
�� �� �� �� rewriteRule tree newSource


Essentially, I used the same search pattern you used, but I used it for the RBParseTreeRewriter and removed all of the RBParseTreeSearcher code. If you want to change all #collect: sends in a method, then you should probably change `@aCollection and `@arg1 to ``@aCollection and ``@arg1.


John Brant