Smalltalk.st
changeset 2270 76c239686353
parent 2249 cdb6c87f0707
child 2317 ff8b15c81a16
--- a/Smalltalk.st	Sat Jan 25 01:43:51 1997 +0100
+++ b/Smalltalk.st	Sat Jan 25 13:13:53 1997 +0100
@@ -703,12 +703,18 @@
      renaming the classVariables (create & copy over values)
      and patching the classes methods to access the new variables."
 
-    |oldName oldSym newSym names oldCVSym newCVSym value oldNameToNewName|
+    |oldName oldSym newSym names oldCVSym newCVSym value oldNameToNewName
+     oldNameSpace newNameSpace privateClasses|
 
     oldName := aClass name.
+    oldNameSpace := aClass nameSpace.
     oldSym := oldName asSymbol.
-
-    ((self at:oldSym) == aClass) ifFalse:[^ self].
+    privateClasses := aClass privateClasses.
+
+    ((self at:oldSym) ~~ aClass) ifTrue:[
+        'Smalltalk [warning]: rename failed - name is different from key' errorPrintCR.
+        ^ self
+    ].
 
     "/ rename the class
 
@@ -735,39 +741,65 @@
 
     names := aClass classVariableString asCollectionOfWords.
     names do:[:name |
-	oldCVSym := (oldSym , ':' , name) asSymbol.
-	value := self at:oldCVSym.
-	self at:oldCVSym put:nil.
-
-	"/
-	"/ see comment in #removeKey: on why we dont remove it it here
-	"/
-	"/ self removeKey:cSym.
-
-	newCVSym := (newSym , ':' , name) asSymbol.
-	self at:newCVSym put:value.
-
-	oldNameToNewName at:oldCVSym put:newCVSym.
+        oldCVSym := (oldSym , ':' , name) asSymbol.
+        value := self at:oldCVSym.
+        self at:oldCVSym put:nil.
+
+        "/
+        "/ see comment in #removeKey: on why we dont remove it it here
+        "/
+        "/ self removeKey:cSym.
+
+        newCVSym := (newSym , ':' , name) asSymbol.
+        self at:newCVSym put:value.
+
+        oldNameToNewName at:oldCVSym put:newCVSym.
     ].
 
     "/ patch methods literal arrays from oldCVname to newCVname
 
     oldNameToNewName keysAndValuesDo:[:oldNameSym :newNameSym |
-	aClass withAllSubclasses do:[:aSubClass |
-	    aSubClass class methodDictionary do:[:aMethod |
-		aMethod changeLiteral:oldNameSym to:newNameSym
-	    ].
-	    aSubClass methodDictionary do:[:aMethod |
-		aMethod changeLiteral:oldNameSym to:newNameSym
-	    ]
-	]
+        aClass withAllSubclasses do:[:aSubClass |
+            aSubClass class methodDictionary do:[:aMethod |
+                aMethod changeLiteral:oldNameSym to:newNameSym
+            ].
+            aSubClass methodDictionary do:[:aMethod |
+                aMethod changeLiteral:oldNameSym to:newNameSym
+            ]
+        ].
+
+        "/ and also in privateClasses ? ...
+
+"/        privateClasses notNil ifTrue:[
+"/            privateClasses do:[:aPrivateClass |
+"/                aPrivateClass withAllSubclasses do:[:aSubClass |
+"/                    aSubClass class methodDictionary do:[:aMethod |
+"/                        aMethod changeLiteral:oldNameSym to:newNameSym
+"/                    ].
+"/                    aSubClass methodDictionary do:[:aMethod |
+"/                        aMethod changeLiteral:oldNameSym to:newNameSym
+"/                    ]
+"/                ].
+"/            ]
+"/        ]
     ].
 
-    aClass addChangeRecordForClassRename:oldSym to:newSym
+    aClass addChangeRecordForClassRename:oldSym to:newSym.
+
+    privateClasses notNil ifTrue:[
+        newNameSpace := aClass nameSpace.
+        oldNameSpace ~~ newNameSpace ifTrue:[
+            "/ must rename privateClasses as well
+            privateClasses do:[:aPrivateClass |
+                self renameClass:aPrivateClass
+                     to:(newNameSpace name , '::' , aPrivateClass nameWithoutNameSpacePrefix)   
+            ]
+        ]
+    ]
 
     "Created: 29.10.1995 / 19:58:32 / cg"
     "Modified: 18.6.1996 / 14:20:50 / stefan"
-    "Modified: 30.10.1996 / 20:23:25 / cg"
+    "Modified: 25.1.1997 / 13:05:16 / cg"
 ! !
 
 !Smalltalk class methodsFor:'copying'!
@@ -3538,5 +3570,5 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.217 1997-01-23 18:13:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.218 1997-01-25 12:13:53 cg Exp $'
 ! !