Lukas, i have the following problem: model := RBNamespace new. Then executing successive RenameRefactoring's using the same model yields an Error. 1. ClassA -> ClassA2 OK 2. ClassA2 -> ClassA3 OK 3. ClassA3 -> ClassA4 ERROR! I've tracked it down to this: 1. RenameRefactoring>>execute self primitiveExecute. RefactoringManager instance addRefactoring: self 2. RefactoringManager>>addRefactoring: aRefactoring RefactoryChangeManager instance performChange: aRefactoring changes. refactorings add: aRefactoring class name 3. Refactoring>>changes ^self model changes which answers all the changes! { ClassA rename: #ClassA2! ClassA2 rename: #ClassA3! ClassA3 rename: #ClassA4! } Why does a particular refactoring answers all the models changes? And not just the ones it introduced? The problem is in #performChange: will apply over and over all the changes, and not just the last one. Lukas, do you think i'm incorrectly using the namespace and refactoring's? Are namespace supposed to be used once and later ditched? My goal is to have a GauchoSystem which nows all the changes (with undos!) that have happened, that's why i'm using always the same namespace. Thanks, Fernando pd: a test that reproduces the problem. >>testSucessiveRefactoringsError | namespace | namespace := RBNamespace new. [ | refactoring| Object subclass: 'ClassA' asSymbol instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'TestingNamespaces1234'. refactoring := RenameClassRefactoring model: namespace rename: (Smalltalk classNamed: 'ClassA' asSymbol ) to: 'ClassA2' asSymbol . refactoring execute. refactoring := RenameClassRefactoring model: namespace rename: (Smalltalk classNamed:'ClassA2' asSymbol ) to: 'ClassA3' asSymbol. refactoring execute. refactoring := RenameClassRefactoring model: namespace rename: (Smalltalk classNamed: 'ClassA3' asSymbol ) to: 'ClassA4' asSymbol. self shouldnt:[refactoring execute] raise: Error description: 'Valid refactoring should not raise error'. ] ensure:[ SystemOrganization removeSystemCategory: 'TestingNamespaces1234' ] _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
2010/3/19 Fernando olivero <[hidden email]>:
> Lukas, i have the following problem: > model := RBNamespace new. > Then executing successive RenameRefactoring's using the same model yields an > Error. > 1. ClassA -> ClassA2 OK > 2. ClassA2 -> ClassA3 OK > 3. ClassA3 -> ClassA4 ERROR! > > I've tracked it down to this: > Lukas, do you think i'm incorrectly using the namespace and refactoring's? Yeah, probably you are using it incorrectly. Just call #primtiveExecute on the refactoring if you only want to apply it to the RBNamespace model. > Are namespace supposed to be used once and later ditched? RBNamespace provides a view on the system that can be manipulated without touching the actual system. The class has a horrible name, it should rather be called RBSmalltalkModel or something. After several operations all the changes can then be applied in a single "atomic" operation using: aNamespace changes execute > My goal is to have a GauchoSystem which nows all the changes (with undos!) > that have happened, that's why i'm using always the same namespace. RBNamespace is a delta to the real system. You don't want to keep it around for too long. You perform some operations on it, you commit them to the image, and then you use a new instance. That's the basic workflow. The undoes are kept separate in RefactoryChangeManager. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Get it now!
Thanks for the clarification. On Mar 19, 2010, at 11:56 AM, Lukas Renggli wrote: > 2010/3/19 Fernando olivero <[hidden email]>: >> Lukas, i have the following problem: >> model := RBNamespace new. >> Then executing successive RenameRefactoring's using the same model yields an >> Error. >> 1. ClassA -> ClassA2 OK >> 2. ClassA2 -> ClassA3 OK >> 3. ClassA3 -> ClassA4 ERROR! >> >> I've tracked it down to this: >> Lukas, do you think i'm incorrectly using the namespace and refactoring's? > > Yeah, probably you are using it incorrectly. > > Just call #primtiveExecute on the refactoring if you only want to > apply it to the RBNamespace model. > >> Are namespace supposed to be used once and later ditched? > > RBNamespace provides a view on the system that can be manipulated > without touching the actual system. The class has a horrible name, it > should rather be called RBSmalltalkModel or something. After several > operations all the changes can then be applied in a single "atomic" > operation using: > > aNamespace changes execute > >> My goal is to have a GauchoSystem which nows all the changes (with undos!) >> that have happened, that's why i'm using always the same namespace. > > RBNamespace is a delta to the real system. You don't want to keep it > around for too long. You perform some operations on it, you commit > them to the image, and then you use a new instance. That's the basic > workflow. > > The undoes are kept separate in RefactoryChangeManager. > > Lukas > > -- > Lukas Renggli > http://www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Fernando olivero
There seem to be some serious bugs when performing a sequence of renames.
I added (a modified version) of your test and fixed the problem in: Name: Refactoring-Core-lr.115 Author: lr Time: 19 March 2010, 1:36:35 pm UUID: 89f629b7-df37-4545-b795-87c5b78e1127 Ancestors: Refactoring-Core-lr.114, Refactoring-Core-lr.113 - fixed some bugs and added some tests when renaming a class multiple times Name: Refactoring-Tests-Core-lr.35 Author: lr Time: 19 March 2010, 1:36 pm UUID: a2c9c388-a1b1-4f7a-a749-f3d658c42779 Ancestors: Refactoring-Tests-Core-lr.33 - fixed some bugs and added some tests when renaming a class multiple times Lukas 2010/3/19 Fernando olivero <[hidden email]>: > Lukas, i have the following problem: > model := RBNamespace new. > Then executing successive RenameRefactoring's using the same model yields an > Error. > 1. ClassA -> ClassA2 OK > 2. ClassA2 -> ClassA3 OK > 3. ClassA3 -> ClassA4 ERROR! > > I've tracked it down to this: > 1. > RenameRefactoring>>execute > self primitiveExecute. > RefactoringManager instance addRefactoring: self > 2. > RefactoringManager>>addRefactoring: aRefactoring > RefactoryChangeManager instance performChange: aRefactoring changes. > refactorings add: aRefactoring class name > 3. > Refactoring>>changes > ^self model changes > which answers all the changes! > { ClassA rename: #ClassA2! > ClassA2 rename: #ClassA3! > ClassA3 rename: #ClassA4! } > Why does a particular refactoring answers all the models changes? And not > just the ones it introduced? > The problem is in #performChange: will apply over and over all the changes, > and not just the last one. > > Lukas, do you think i'm incorrectly using the namespace and refactoring's? > Are namespace supposed to be used once and later ditched? > My goal is to have a GauchoSystem which nows all the changes (with undos!) > that have happened, that's why i'm using always the same namespace. > > Thanks, > Fernando > > pd: a test that reproduces the problem. > >>>testSucessiveRefactoringsError > | namespace | > namespace := RBNamespace new. > [ > | refactoring| > Object subclass: 'ClassA' asSymbol > instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'TestingNamespaces1234'. > refactoring := RenameClassRefactoring > model: namespace > rename: (Smalltalk classNamed: 'ClassA' asSymbol ) > to: 'ClassA2' asSymbol . > refactoring execute. > refactoring := RenameClassRefactoring > model: namespace > rename: (Smalltalk classNamed:'ClassA2' asSymbol ) > to: 'ClassA3' asSymbol. > refactoring execute. > refactoring := RenameClassRefactoring > model: namespace > rename: (Smalltalk classNamed: 'ClassA3' asSymbol ) > to: 'ClassA4' asSymbol. > self shouldnt:[refactoring execute] raise: Error description: 'Valid > refactoring should not raise error'. > ] ensure:[ SystemOrganization removeSystemCategory: 'TestingNamespaces1234' > ] > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |