> On 31 Aug 2015, at 08:52, Marcus Denker <[email protected]> wrote:
>
>
>>
>> The only problem is that it does a whole-method refactoring while it should
>> only affect the node
>> that triggered the deprecation. Else there could be wrong transformations if
>> the same selector
>> is used but only one of the implementations need to be rewritten, while if
>> we are able to rewrite
>> the exact sender, we can do it fully automatically.
>>
>
> I think using #sourceNodeExecuted we could do it like this:
>
even simpler:
deprecated: anExplanationString rule: aRule
| rewriteRule method context node |
context := thisContext sender sender.
method := context method.
node := context sourceNodeExecuted.
rewriteRule := RBParseTreeRewriter new replace: aRule key with: aRule
value.
(rewriteRule executeTree: node) ifFalse: [ ^self ].
node replaceWith: rewriteRule tree.
method methodClass compile: method ast formattedCode classified: method
protocol.
It seems to work but I have not tested it too much.
Marcus