Fix OB refactoring: Creating accessor change the instance/class variable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Fix OB refactoring: Creating accessor change the instance/class variable

Mathieu SUEN
Hi,

If you use the refactoring create  accessor for instance or class  
variable some time fails:

If you have a class define as:

Object subclass: #A
        instanceVariableNames: 'c b'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'Dummy'


And add A>>b: by hand.
After create the accessor for c with the refactoring in omnibrowser.

"A new b: 3"  will affect c and not b.
This is because ob-refactoring sort the instance variable to display  
in the alphabetical order:

ORCmdRefactoring>>instanceVariables
        ^ (target isKindOf: OBInstanceVariableNode)
                ifTrue: [ Array with: target name ]
                ifFalse: [ target theClass instVarNames asArray sort ]

I have patched this method with the #asSortedArray. See the attached  
file

I think is the method #asArray who make the mess if you look at the  
implementation of Array>>#asArray.
I would rather expect a copy of self.


I have open an issue: http://bugs.squeak.org/view.php?id=6602





        Mth






FixOBAccessorRefactoring.2.cs (788 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fix OB refactoring: Creating accessor change the instance/class variable

Lukas Renggli
Thanks for reporting. I published a fixed version:

Name: OB-Refactory-lr.32
Author: lr
Time: 11 August 2007, 3:30:11 pm
UUID: a4e57fc6-dd44-4e60-80ff-f0ae3642ad84
Ancestors: OB-Refactory-lr.31

- fixed the bug reported by mathieu (inst-var/class-var ordering
caused corruption of classes in some cases)

Ken, could you please close the bug-report, it was assigned to you.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch