> 
> 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:

deprecated: anExplanationString rule: aRule
        | builder rewriteRule method context node |
        builder := RBCompositeRefactoryChange named: 'deprecation'.
        method := thisContext sender sender method.
        context :=  thisContext sender sender.
        node := context sourceNodeExecuted.
        rewriteRule := RBParseTreeRewriter new replace: aRule key with: aRule 
value.
        (rewriteRule executeTree: node copy)
                ifTrue: [ 
                        node replaceWith: rewriteRule tree.     
                        builder compile: method ast formattedCode in: method 
methodClass classified: method protocol ].
        builder execute.


And a question is if we need #formattedCode… all refactoring normally try to 
update white-space information. 
Need to check.

        Marcus

Reply via email to