[Pharo-project] rename a method programatically

Cyrille Delaunay cy.delaunay at gmail.com
Wed Nov 24 11:03:56 CET 2010


If someone wants to know, this is the I'm doing it:

  refactoring := RenameMethodRefactoring renameMethod: #oldMethodMethod in:
class to: #newMethod permutation: (#()).
  refactoring execute.

2010/11/24 Cyrille Delaunay <cy.delaunay at gmail.com>

> Ok, thank you :)
>
> 2010/11/24 Mariano Martinez Peck <marianopeck at gmail.com>
>
>
>>
>> On Wed, Nov 24, 2010 at 9:44 AM, Tudor Girba <tudor.girba at gmail.com>wrote:
>>
>>> I was also referring to a programatic solution :). Perhaps the name is
>>> misleading, but RB is not the UI. RB is primarily the engine behind that
>>> contains the logic of performing a refactoring.
>>>
>>>
>> Exactlly. The UI can be OB-Refactory, or Gaucho, or just programatic.
>>
>>
>>> Doru
>>>
>>> On 24 Nov 2010, at 09:17, Cyrille Delaunay wrote:
>>>
>>> > Indeed, in my case I would like to do that wihtout using UI. I want to
>>> write a test in which I rename a method and see if the events emited have
>>> been well-catched by RPackage.
>>> >
>>> > 2010/11/24 Igor Stasenko <siguctua at gmail.com>
>>> > On 24 November 2010 02:00, Tudor Girba <tudor.girba at gmail.com> wrote:
>>> > > Well, as long as you want to perform a refactoring I believe that RB
>>> provides the API in question.
>>> > >
>>> > Yes, of course. But question was 'how to do that programmatically' ,
>>> > not using browser or other UI.
>>> >
>>> > > Doru
>>> > >
>>> > >
>>> > > On 24 Nov 2010, at 00:52, Igor Stasenko wrote:
>>> > >
>>> > >> On 24 November 2010 01:43, Tudor Girba <tudor.girba at gmail.com>
>>> wrote:
>>> > >>> Definitely use the RB for any code transformations.
>>> > >>>
>>> > >>
>>> > >> I don't think it's a good option for meta-programming.
>>> > >> For meta-programming, basic interface in Behavior or
>>> ClassDescription
>>> > >> should be enough for manipulating
>>> > >> with methods, without dependency from RB.
>>> > >> Actually, RB then can use same API for manipulations.
>>> > >>
>>> > >>> Cheers,
>>> > >>> Doru
>>> > >>>
>>> > >>>
>>> > >>> On 23 Nov 2010, at 19:01, Mariano Martinez Peck wrote:
>>> > >>>
>>> > >>>> Cyrille I don't know why you need that but take into account that
>>> RB split their packages even more in the last months. So maybe it is easier
>>> for you to directly use RB and load with your code, the RB core or the
>>> specific package that you need. Mostly if you need some other similar
>>> functionalities.
>>> > >>>>
>>> > >>>> Cheers
>>> > >>>>
>>> > >>>> Mariano
>>> > >>>>
>>> > >>>> On Tue, Nov 23, 2010 at 6:56 PM, jaayer <jaayer at zoho.com> wrote:
>>> > >>>>
>>> > >>>>
>>> > >>>>
>>> > >>>>
>>> > >>>> ---- On Tue, 23 Nov 2010 05:17:05 -0800 Cyrille Delaunay  wrote
>>> ----
>>> > >>>>
>>> > >>>>> Hello,
>>> > >>>>>
>>> > >>>>> I would like to know how I can rename a method programatically
>>> and safelly (without missing to raise any event that has to be raised)
>>> > >>>>>
>>> > >>>>
>>> > >>>> I don't believe there is any simple way to do this.
>>> > >>>>
>>> > >>>> Basically, to rename a method you have to remove it first and
>>> compile into its class a new method containing the same source code but with
>>> a different selector at the beginning. This is how the refactory browser
>>> does it when you select "rename" from the "refactor method" menu. If anyone
>>> knows of a better way, I would be interested to hear it.
>>> > >>>>
>>> > >>>>
>>> > >>>>
>>> > >>>
>>> > >>> --
>>> > >>> www.tudorgirba.com
>>> > >>>
>>> > >>> "To lead is not to demand things, it is to make them happen."
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Best regards,
>>> > >> Igor Stasenko AKA sig.
>>> > >>
>>> > >
>>> > > --
>>> > > www.tudorgirba.com
>>> > >
>>> > > "Not knowing how to do something is not an argument for how it cannot
>>> be done."
>>> > >
>>> > >
>>> > >
>>> >
>>> >
>>> >
>>> > --
>>> > Best regards,
>>> > Igor Stasenko AKA sig.
>>> >
>>> >
>>>
>>> --
>>> www.tudorgirba.com
>>>
>>> "Problem solving efficiency grows with the abstractness level of problem
>>> understanding."
>>>
>>>
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20101124/1b154c49/attachment.htm>


More information about the Pharo-project mailing list