class: ClassDefinitionChange
authorClaus Gittinger <cg@exept.de>
Wed, 27 Mar 2013 19:18:21 +0100
changeset 3150 10fa70a50dfa
parent 3149 2a6e57be3b56
child 3151 7b9ea70d52bf
class: ClassDefinitionChange added: #localClassName comment/format in: #isPrivateClassDefinitionChange changed: #definitionString ouch: generated wrong definition string code for private classes (full name instead of local name)
ClassDefinitionChange.st
--- a/ClassDefinitionChange.st	Wed Mar 27 17:49:12 2013 +0100
+++ b/ClassDefinitionChange.st	Wed Mar 27 19:18:21 2013 +0100
@@ -50,7 +50,7 @@
 !ClassDefinitionChange class methodsFor:'others'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/ClassDefinitionChange.st,v 1.74 2013-03-26 12:14:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/ClassDefinitionChange.st,v 1.75 2013-03-27 18:18:21 cg Exp $'
 ! !
 
 !ClassDefinitionChange methodsFor:'accessing'!
@@ -157,6 +157,20 @@
     instanceVariableNames := something.
 !
 
+localClassName
+    "for private classes, this returns the name relative to its owner;
+     for non-private ones, this is the regular name.
+     Notice that className always returns the full name (incl. any owner prefix)"
+
+    self isPrivateClassDefinitionChange ifFalse:[^ self className].
+    (className startsWith:(owningClassName,'::')) ifTrue:[
+        ^ className copyFrom:(owningClassName size + 2 + 1).
+    ] ifFalse:[
+        "/ should not happen
+        ^ self className
+    ]
+!
+
 nameSpaceName
     objectType == #variable ifTrue:[
         ^ nil
@@ -378,7 +392,10 @@
     ].
 
     superClassNameUsed := self superClassName.
-    classNameUsed := self className.
+    "/ careful with private classes: the definition MUST give the
+    "/ local name as argument, not the full name
+    classNameUsed := self localClassName.
+
     selPart := (self definitionSelector ? #'subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:')
                     keywords first.         
 
@@ -613,6 +630,8 @@
 !
 
 isPrivateClassDefinitionChange
+    "compute lazily; remember in private"
+
     private isNil ifTrue:[
         (className includes:$:) ifFalse:[
             "/ cannot be private
@@ -767,7 +786,7 @@
 !ClassDefinitionChange class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/ClassDefinitionChange.st,v 1.74 2013-03-26 12:14:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/ClassDefinitionChange.st,v 1.75 2013-03-27 18:18:21 cg Exp $'
 !
 
 version_SVN