2011/1/12 Lukas Renggli <renggli@gmail.com>:
The stack-trace and your code snippet does not match. There are no references (and should be no references) to #compileTree: or RBClass in the code you pasted into the mail.
The thing was to replace the line marked with [1] as I've commented above. If you file in the attached dummy class and evaluate the following script should be reproduceable: | className realClass replacer category | className := #MyClass. realClass := Smalltalk at: className. category := #accessing. replacer := RBParseTreeRewriter new replace: '`receiver asString' with: '`receiver asText'; yourself. (realClass organization listAtCategoryNamed: category) collect: [:sel | | parseTree | parseTree := ( realClass >> sel) parseTree. (replacer executeTree: parseTree) ifTrue: [ ( RBClass existingNamed: className ) compileTree: replacer tree ] ]
The easiest is probably if you use the refactoring tools as integrated into OB. This does all automatically.
It should be too obvious but I didn't find how. May you comment how to perform the task in the script with OB? Thanks, Hernán
Lukas
On 12 January 2011 08:47, Hernán Morales Durand <hernan.morales@gmail.com> wrote:
2011/1/12 Lukas Renggli <renggli@gmail.com>:
1) In [1] "( RBClass existingNamed: className ) compileTree: replacer tree" would be more appropiate? I get a MNU when evaluated with latest AST/Refactoring.
What kind of MNU?
Debug log attached
2) The above script have some problems, if you want to get replaced
'this is a string' asString.
to
'this is a string' asText
it won't match. The same happens with: " self model asString " and other patterns.
`#literal asString
i.e. [: tmp | anObject1 blabla1 blabla2 oldMessage blabla3 ] How to modify the rewriter to match oldMessage/newMessage at any point?
``@obj oldMessage
Lukas
Cool, thanks!
-- Lukas Renggli www.lukas-renggli.ch