ClassInitializeChange.st
changeset 3522 1f72f0fbdcf8
child 3532 2491adb43cf2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ClassInitializeChange.st	Fri Mar 21 19:32:07 2014 +0100
@@ -0,0 +1,74 @@
+"{ Package: 'stx:libbasic3' }"
+
+ClassChange subclass:#ClassInitializeChange
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'System-Changes'
+!
+
+!ClassInitializeChange class methodsFor:'documentation'!
+
+documentation
+"
+    Change for class initialization chunk. Unlike DoItChange, 
+    ClassInitializeChange handles namespaces and private classes
+    properly.
+
+    [author:]
+        Jan Vrany <jan.vrany@fit.cvut.cz>
+
+    [instance variables:]
+
+    [class variables:]
+
+    [see also:]
+
+"
+! !
+
+!ClassInitializeChange methodsFor:'accessing'!
+
+source
+    "return the source of the change"
+
+    source isNil ifTrue:[
+        ^ String streamContents:[ :s | 
+            (nameSpaceName notNil and:[ nameSpaceName ~= 'Smalltalk' ]) ifTrue:[ 
+                s nextPutAll: '"{ NameSpace: '; nextPutAll: nameSpaceName; nextPutAll: ' }"'; cr; cr.
+                s nextPutAll: self className; nextPutAll: ' initialize!!'; cr.   
+            ].
+        ]
+    ].
+    ^ source
+
+    "Created: / 21-03-2014 / 17:43:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ClassInitializeChange methodsFor:'applying'!
+
+apply
+    "apply the change"
+
+    | class |
+
+    class := self changeClass.
+    class isNil ifTrue:[ 
+        self error:('Class %1 does not (yet?) exists' bindWith: self fullClassName).
+        ^ self.
+    ].
+    class initialize.
+
+    "Created: / 21-03-2014 / 17:38:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ClassInitializeChange class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libbasic3/ClassInitializeChange.st,v 1.1 2014-03-21 18:32:07 vrany Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/libbasic3/ClassInitializeChange.st,v 1.1 2014-03-21 18:32:07 vrany Exp $'
+! !
+