class: VSEPackageFileSourceWriter
authorClaus Gittinger <cg@exept.de>
Thu, 05 Feb 2015 12:35:28 +0100
changeset 3756 30fb6df85906
parent 3755 ec8b6c0b0827
child 3757 437dd4927111
class: VSEPackageFileSourceWriter class definition changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder: #fileOutCategory:of:except:only:methodFilter:on: #fileOutDefinitionOf:on: #fileOutPackage:on: deal with comments and initializers
VSEPackageFileSourceWriter.st
--- a/VSEPackageFileSourceWriter.st	Thu Feb 05 12:13:02 2015 +0100
+++ b/VSEPackageFileSourceWriter.st	Thu Feb 05 12:35:28 2015 +0100
@@ -14,7 +14,7 @@
 "{ NameSpace: Smalltalk }"
 
 VSEFileSourceWriter subclass:#VSEPackageFileSourceWriter
-	instanceVariableNames:'projectDefinitionClass'
+	instanceVariableNames:'projectDefinitionClass classesToBeInitialized'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Kernel-Classes-Support'
@@ -75,6 +75,8 @@
 !VSEPackageFileSourceWriter methodsFor:'source writing'!
 
 fileOut:aClass on:aStream withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter encoder:encoderOrNil
+    |commentOrDocumentation skipDocumentationMethod|
+
     aStream nextPutAll:'Class '.
     aStream nextPutAll:(self rewrittenClassNameOf:aClass).
     aStream space.
@@ -84,6 +86,17 @@
     aStream nextPutAll:(self rewrittenClassNameOf:aClass superclass).
     aStream nextPutLine:'!!'.
 
+    skipDocumentationMethod := false.
+    (commentOrDocumentation := aClass comment) isEmptyOrNil ifTrue:[
+        (commentOrDocumentation := aClass commentOrDocumentationString) notEmptyOrNil ifTrue:[
+            skipDocumentationMethod := true
+        ].
+    ].
+    commentOrDocumentation notEmptyOrNil ifTrue:[
+        self putEntry:'Property' value:'Comment' on:aStream.
+        self putEntry:'' value:commentOrDocumentation on:aStream.
+    ].
+
     aClass isVariable ifTrue:[
         aClass isPointers ifTrue:[
             aStream nextPutLine:'IndexableObject!!'.
@@ -110,7 +123,11 @@
         self fileOutMethod:(aClass methodDictionary at:sel) isExtension:false on:aStream.
     ].
     aClass class methodDictionary keys asNewOrderedCollection sort do:[:sel |
-        self fileOutMethod:(aClass class methodDictionary at:sel) isExtension:false on:aStream.
+        (skipDocumentationMethod and:[sel == #documentation]) ifTrue:[
+            "/ skip method
+        ] ifFalse:[
+            self fileOutMethod:(aClass class methodDictionary at:sel) isExtension:false on:aStream.
+        ].
     ].
 
     self putEntry:'EndClass' value:nil on:aStream.
@@ -125,6 +142,7 @@
 
     |sortedSelectors first prevPrivacy privacy interestingMethods|
 
+self halt:'should not be called'.
     interestingMethods := OrderedCollection new.
     aClass methodsDo:[:aMethod |
         |wanted|
@@ -198,6 +216,7 @@
 
     |s owner ns superclass nm|
 
+self halt:'should not be called'.
     owner := aClass owningClass.
     ns := aClass topNameSpace.
 
@@ -390,6 +409,7 @@
     |classesToFileout methodsToFileOut rewriter|
 
     projectDefinitionClass := packageID asPackageId projectDefinitionClass.
+    classesToBeInitialized := OrderedCollection new.
 
     aStream lineEndCRLF.
 
@@ -422,7 +442,10 @@
     ] do:[
         classesToFileout do:[:eachClass |
             self activityNotification:'exporting ',eachClass name,'...'.
-            self fileOut:eachClass on:aStream
+            self fileOut:eachClass on:aStream.
+            (eachClass theMetaclass includesSelector:#initialize) ifTrue:[
+                classesToBeInitialized add:eachClass.
+            ].
         ].
 
         "/ fileout extensions
@@ -432,16 +455,29 @@
             aStream cr.
         ].
     ].
+
+    classesToBeInitialized notEmpty ifTrue:[
+        |initializerCode|
+
+        initializerCode := String 
+            streamContents:[:s |
+                classesToBeInitialized do:[:eachClass |
+                    s nextPutLine:(self rewrittenClassNameOf:eachClass), ' initialize.'.
+                ]
+            ].
+        self putEntry:'Initialization' value:initializerCode on:aStream.
+    ].
+
     self activityNotification:'done.'.
 ! !
 
 !VSEPackageFileSourceWriter class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/VSEPackageFileSourceWriter.st,v 1.9 2015-02-05 11:13:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/VSEPackageFileSourceWriter.st,v 1.10 2015-02-05 11:35:28 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/VSEPackageFileSourceWriter.st,v 1.9 2015-02-05 11:13:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/VSEPackageFileSourceWriter.st,v 1.10 2015-02-05 11:35:28 cg Exp $'
 ! !