Oh! Thanks!! So the correct message to send is execute. The transform actually do nothing, it only stores the changes that are executed by the RBRefactoryChangeManager.
On Wed, May 27, 2020 at 6:27 AM Thierry Goubier <thierry.goub...@gmail.com> wrote: > Hi Vitor, > > I got it to work (integrated it as a command into my IDE, and wrote > the auto-detect part for the permutation), with the following > algorithm (I've removed the IDE-specific part): > > | aClass aSel newSel ast aMap | > aClass := RefactoringReformatExample. > aSel := #with:doThis: > newSel := UIManager default > request: 'Enter the new selector and arguments' > initialAnswer: (aClass >> aSel) ast selectorAndArgumentNames. > (newSel isNil or: [ newSel isEmpty ]) > ifTrue: [ self inform: 'Cancelled'. > ^ self ]. > ast := aClass compiler parse: newSel. > aMap := ast argumentNames > collect: [ :e | > (aClass >> aSel) ast argumentNames > indexOf: e > ifAbsent: [ self error: 'Incorrect argument name: ' , e. > ^ self ] ]. > (RBRenameMethodRefactoring > renameMethod: aSelector > in: aClass > to: ast selector > permutation: aMap) execute > > If your initial method is 'with: arg1 doThis: arg2', you write the new > selector as 'doThis: arg2 with: arg1' and it will pick up the > permutation map for you. > > Thierry > > Le mar. 26 mai 2020 à 17:05, Vitor Medina Cruz <vitormc...@gmail.com> a > écrit : > > > > Will wait then. > > > > I tried to use the RB classes but with no success. There are few docs > and test code are hard to understand (still not sure if I should use > transform ou primitiveExecute). I did this: > > > > (RBRenameMethodRefactoring new > > renameMethod: #with:doThis: > > in: RefactoringReformatExample > > to: #withh:doThis: > > permutation: #(1 2)) primitiveExecute > > > > and > > > > (RBRenameMethodRefactoring new > > renameMethod: #with:doThis: > > in: RefactoringReformatExample > > to: #withh:doThis: > > permutation: #(1 2)) tranform > > > > but nothing happens... It is really odd, I expected an error at least. > > > > I am assuming permutation means the change of params order. > > > > > > On Fri, May 22, 2020 at 3:50 AM Stéphane Ducasse < > stephane.duca...@inria.fr> wrote: > >> > >> we are working with sebastian jordan on a better rewriter. > >> > >> S. > >> > >> On 21 May 2020, at 17:17, Vitor Medina Cruz <vitormc...@gmail.com> > wrote: > >> > >> Interesting, I will have a look at it. > >> > >> On Thu, May 21, 2020 at 11:52 AM Thierry Goubier < > thierry.goub...@gmail.com> wrote: > >>> > >>> Hi Vitor, > >>> > >>> as a matter of fact, the infrastructure for doing what you're looking > >>> for is already there. > >>> > >>> The algorithm is the following: > >>> > >>> - create a scope (something based on RBBrowserEnvironment, such as > >>> RBClassEnvironment or based on regexes and AND / OR operations: > >>> RBAndEnvironment, RBNotEnvironment, which allows for virtually > >>> anything, such as all #printString methods in the package X that do > >>> not belong to class Y) > >>> > >>> - create a refactoring command: if it is not a pre-existing command > >>> such as rename class, etc..., then writing a pattern matcher is > >>> possible with RBTreeRewriter. > >>> > >>> - execute the refactoring command on the environment, changing only > >>> for the subset of code visible in the environment. > >>> > >>> Normally, the system browser or the search tools should automatically > >>> setup the environment for you, and scope accordingly most of the > >>> refactoring commands. As far as I know, there isn't yet a shell giving > >>> you the full pattern matching rewrite power, but some work was > >>> underway (GUI tools). > >>> > >>> Going with the source files as you did also work... > >>> > >>> Regards, > >>> > >>> Thierry > >>> > >>> Le jeu. 21 mai 2020 à 15:30, Vitor Medina Cruz <vitormc...@gmail.com> > a écrit : > >>> > > >>> > Well, as it seems, there is no way of find/replacing other than > inside a single method. > >>> > > >>> > As a workaround, I did the following: > >>> > > >>> > 1- Committed all my image work in progress; > >>> > 2- Opened the project structure in an external tool (notepad++ in > this case) and did the find/replace there; > >>> > 3- Committed it using git command line; > >>> > 4- Back to the image, I did a repair repository from iceberg > checking out and ignoring changes to the image (safe because I did commit > everything before) > >>> > > >>> > If there are many places to change, it is worth. > >>> > > >>> > Regards, > >>> > Vitor > >>> > > >>> > On Tue, May 19, 2020 at 12:56 PM Vitor Medina Cruz < > vitormc...@gmail.com> wrote: > >>> >> > >>> >> Hello, > >>> >> > >>> >> Is there a way to make find replace in a class scoped way? I can do > that with finder, but I figured only with package scoping. I wanna to > change the name of a variable in multiple methods, and also I would like to > regex replace an expression also in multiple methods. > >>> >> > >>> >> Regards, > >>> >> Vitor > >>> > >> > >> -------------------------------------------- > >> Stéphane Ducasse > >> http://stephane.ducasse.free.fr / http://www.pharo.org > >> 03 59 35 87 52 > >> Assistant: Aurore Dalle > >> FAX 03 59 57 78 50 > >> TEL 03 59 35 86 16 > >> S. Ducasse - Inria > >> 40, avenue Halley, > >> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza > >> Villeneuve d'Ascq 59650 > >> France > >> > >