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
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to