I have a whole hierarchy of classes with some prefix AA. I generated a clone of the hierarchy with a prefix like BB.
Now I am happy with the changes I've made to BBClass and want to replace the AAClass hierarchy with the BBClass hierarchy by deleting the AAClasses and renaming BBClasses to AAClasses. This is my script:
| list bbDict | list := AAClass withAllSubclasses asArray. bbDict := Dictionary new. list do: [:ea | bbDict at: ea bbClass put: ea name]. list do: [:cls | Smalltalk removeClass: cls]. bbDict keysAndValuesDo:[:k :v | Smalltalk renameClass: k as: v].
This doesn't seem to properly complete the job and leaves SystemDictionary and the new AAClasses in a weird state.
What am I missing?
-Todd Blanchard
Todd Blanchard a écrit :
I have a whole hierarchy of classes with some prefix AA. I generated a clone of the hierarchy with a prefix like BB.
Now I am happy with the changes I've made to BBClass and want to replace the AAClass hierarchy with the BBClass hierarchy by deleting the AAClasses and renaming BBClasses to AAClasses. This is my script:
| list bbDict | list := AAClass withAllSubclasses asArray. bbDict := Dictionary new. list do: [:ea | bbDict at: ea bbClass put: ea name]. list do: [:cls | Smalltalk removeClass: cls]. bbDict keysAndValuesDo:[:k :v | Smalltalk renameClass: k as: v].
This doesn't seem to properly complete the job and leaves SystemDictionary and the new AAClasses in a weird state.
Here is what I found in omnibrowser code.
To remove a class: ------------------
yourClass theNonMetaClass removeFromSystem.
To rename a class: ------------------
yourClass theNonMetaClass environment renameClassNamed: oldName as: newName asSymbol.
Browse obsolete references: ---------------------------
| binding | binding := yourClass theNonMetaClass environment associationAt: aClassNode theNonMetaClass name.
(SystemNavigation default allCallsOn: binding) inspect
Hope this helps
Bye
Todd Blanchard wrote:
I have a whole hierarchy of classes with some prefix AA. I generated a clone of the hierarchy with a prefix like BB.
Now I am happy with the changes I've made to BBClass and want to replace the AAClass hierarchy with the BBClass hierarchy by deleting the AAClasses and renaming BBClasses to AAClasses.
How about:
- fileout your BB classes - use an editor (the Squeak file browser for example) to search&replace BB with AA - filein - remove all your BB classes - note: all the original AA instances will be migrated
squeak-dev@lists.squeakfoundation.org