Yes. I think it is possible to work around it by using the dictionary itself, storing the node selector in it in the replace: pattern and retrieving it in the with: pattern.
rewriter replace: ('`#oldSelector `{:node :dic | (node value isSymbol and: [node value matchesRegex: ''.*oldSelector.*'']) ifTrue: [dic at: #selector put: node value. true] ifFalse: [false] }') with: ('`{:dic | RBLiteralNode value: ((dic at: #selector) copyReplaceAll: ''oldSelector'' with: ''newSelector'') asSymbol }').
Wow, that's very cool. I wasn't aware that I could pass arguments (like the dict in this case). This is powerful.
Yes, quite significant. Also the fact the dictionary is cleared for each match (so that it can be reused for the next match in the same ast).
awesome.
Thank you RB Jedi.
I've had the guidance of John Brant (and spent some time over the SmaCC code where he uses it)...
Now, maybe correcting RB in Gemstone is something to do, as well.
Yes. So with the dict workaround you said, it DID work, but when I continue a little more and I found out where was the closure being generated, and that is RBPatternBlockNode >> #createBlockFor: And yeah, the way it was being generated the closure ("source evalauted") was binding "self" to nil. I found a way to make it bind the real self and that worked too. So...time to fork RB for GemStone and commit the fix :)
You're now the maintainer of RB for GemStone! Congratulations :)
ahhahahaha. You know what is funny? I run all AST-Tests-Core from Pharo and NONE halt on #createBlockFor: ... I even run all those from Refactoring-Tests-Core. *So..it seems there is not tests that covers the usage of #createBlockFor: :(*
BTW, do you image other cases like this?
You mean storing those RB rules? I try to collect them if I see some (or participate to), or remember where I see them.
No, I mean the compilation of block closures that would try to bind "self". Anyway, I will search if I find more.
I used to know where the RBRewriteTree chapter was in the Pharo books, but it seems to have disappeared, so I have recreated a copy that I'll try to update.
Thanks, please share it with me when you made it because I could not find it weeks ago.
Thanks!
You're welcome. You are giving opportunities to improve which is what I need (need to practice, need to practice, need to practice...).
ahahahahahha :)
I have ideas for Mark Rizun's tool, but I don't have the time to work on them.
Thierry
Thanks ! -- Mariano http://marianopeck.wordpress.com