Hello Pharo users,
I'm pleased to announce the release of Deprecator.
It's a prototype of a small tool that permits you to deprecate method by annotating them with a <deprecated: ...> pragma.
This pragma takes a rewrite expression as argument that specifies how to rewrite the message send to the deprecated method.
If such a deprecated method is executed, a warning is thrown and a debugger opens.
This debugger has a little 'Rewrite' button that permits to rewrite the sending method according to the rewrite expression and then resume the execution with the new rewritten sending method :)
The implementation is a proof-of-concept and is a bit hacky here and there, but it works.
Example:
You have a class C with a method that you deprecate.
Its rewrite expression tells that if it's executed as the result of a message send of the form:
<receiver> deprecatedMethodArg1: <arg1> arg2: <arg2>,
this message send should be rewritten to:
<receiver> replacementMethodArg1: <arg2> arg2: <arg1>.
Note you can change the order of arguments or even the receiver.
C>>deprecatedMethodArg1: o1 arg2: o2
<deprecated: '`@receiver replacementMethodArg1: `@arg2 arg2: `@arg1'>
^ #deprecated
C>>replacementMethodArg1: o1 arg2: o2
^ #replacement
C>>senderMethod
^ self deprecatedMethodArg1: 1 + 1 arg2: 2 + 2.
Then if you execute C new senderMethod, and then click on the "Rewrite" button of the debugger, then sending method is rewritten to:
C>>senderMethod
^ self replacementMethodArg1: 2 + 2 arg2: 1 + 1.
and the result is #replacement.
The repo is on sSmalltalkHub:
MCHttpRepository
user: ''
password: ''
I hope for comments, feature suggestions, code reviews, contributors, etc :)
BTW, if you have a better name for this project let me know!
For example, I thought about Ammonite because it's an extinct animal (analogy with deprecated) and it fits the sea naming theme.
Cheers,
Camille