Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-ul.275.mcz==================== Summary ====================
Name: Tools-ul.275
Author: ul
Time: 2 November 2010, 1:22:22.534 am
UUID: d003e353-6573-484e-b6f6-8e337da6d123
Ancestors: Tools-ul.274
- fix: copy class instance variables and class comments when creating a copy of a class
=============== Diff against Tools-ul.274 ===============
Item was changed:
----- Method: Browser>>copyClass (in category 'class functions') -----
copyClass
+ | originalClass originalName copysName |
- | originalName copysName oldDefinition newDefinition |
classListIndex = 0 ifTrue: [^ self].
self okToChange ifFalse: [^ self].
+ originalClass := self selectedClass.
+ originalName := originalClass name.
- originalName := self selectedClass name.
copysName := self request: 'Please type new class name' initialAnswer: originalName.
copysName = '' ifTrue: [^ self]. " Cancel returns '' "
copysName := copysName asSymbol.
copysName = originalName ifTrue: [^ self].
(Smalltalk hasClassNamed: copysName)
ifTrue: [^ self error: copysName , ' already exists'].
+ Cursor wait showWhile: [
+ | newDefinition newMetaDefinition newClass |
+ newDefinition := originalClass definition
+ copyReplaceAll: originalName printString
+ with: copysName printString.
+ newClass := Compiler evaluate: newDefinition logged: true.
+ newMetaDefinition := originalClass class definition
+ copyReplaceAll: originalClass class name
+ with: newClass class name.
+ Compiler evaluate: newMetaDefinition logged: true.
+ newClass copyAllCategoriesFrom: originalClass.
+ newClass class copyAllCategoriesFrom: originalClass class.
+ originalClass hasComment ifTrue: [
+ newClass comment: originalClass comment ] ].
- oldDefinition := self selectedClass definition.
- newDefinition := oldDefinition copyReplaceAll: '#' , originalName asString with: '#' , copysName asString.
- Cursor wait
- showWhile: [| class |
- class := Compiler evaluate: newDefinition logged: true.
- class copyAllCategoriesFrom: (Smalltalk at: originalName).
- class class copyAllCategoriesFrom: (Smalltalk at: originalName) class].
self classListIndex: 0.
self changed: #classList!