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

Mathieu Suen mathk.sue at gmail.com
Sat Aug 11 12:59:39 UTC 2007


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



-------------- next part --------------
A non-text attachment was scrubbed...
Name: FixOBAccessorRefactoring.2.cs
Type: application/octet-stream
Size: 587 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070811/4c1bcc87/FixOBAccessorRefactoring.2.obj
-------------- next part --------------

	Mth





More information about the Squeak-dev mailing list