How to rename a lot of classes at once?

Damien Cassou damien.cassou at laposte.net
Tue Dec 26 09:49:53 UTC 2006


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
	



More information about the Squeak-dev mailing list