BeeProjectWriter.st
branchjv
changeset 4396 5333bef41730
parent 4380 d245eab75d0c
equal deleted inserted replaced
4395:96eb18f215e5 4396:5333bef41730
    12 "{ Package: 'stx:libbasic3' }"
    12 "{ Package: 'stx:libbasic3' }"
    13 
    13 
    14 "{ NameSpace: Smalltalk }"
    14 "{ NameSpace: Smalltalk }"
    15 
    15 
    16 Object subclass:#BeeProjectWriter
    16 Object subclass:#BeeProjectWriter
    17 	instanceVariableNames:'name version author timestamp description classesToBeInitialized'
    17 	instanceVariableNames:'name version author timestamp description classesToBeInitialized
       
    18 		writer'
    18 	classVariableNames:''
    19 	classVariableNames:''
    19 	poolDictionaries:''
    20 	poolDictionaries:''
    20 	category:'Kernel-Classes-Support'
    21 	category:'Kernel-Classes-Support'
    21 !
    22 !
    22 
    23 
   158     "/ name := nil.
   159     "/ name := nil.
   159     author := OperatingSystem getFullUserName.
   160     author := OperatingSystem getFullUserName.
   160     version := timestamp := Timestamp now.
   161     version := timestamp := Timestamp now.
   161     description := 'Not yet described'.
   162     description := 'Not yet described'.
   162     classesToBeInitialized := Dictionary new.
   163     classesToBeInitialized := Dictionary new.
       
   164     writer := BeeSourceWriter new.
       
   165 
   163 
   166 
   164     "/ super initialize.   -- commented since inherited method does nothing
   167     "/ super initialize.   -- commented since inherited method does nothing
   165 
   168 
   166     "Modified: / 07-09-2016 / 14:39:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   169     "Modified: / 26-10-2018 / 11:46:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   167 ! !
   170 ! !
   168 
   171 
   169 !BeeProjectWriter methodsFor:'private'!
   172 !BeeProjectWriter methodsFor:'private'!
   170 
   173 
   171 mappings
   174 mappings
   179     mappings at: 'DESCRIPTION' put: description.
   182     mappings at: 'DESCRIPTION' put: description.
   180     ^ mappings
   183     ^ mappings
   181 
   184 
   182     "Created: / 02-11-2015 / 16:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   185     "Created: / 02-11-2015 / 16:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   183     "Modified: / 07-09-2016 / 14:21:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   186     "Modified: / 07-09-2016 / 14:21:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   187 !
       
   188 
       
   189 selectClassesFrom: aCollection 
       
   190     ^ aCollection reject:[:class | class isProjectDefinition or:[ class isSharedPool ] ]
       
   191 
       
   192     "Created: / 29-10-2018 / 15:45:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   193 !
       
   194 
       
   195 selectExtensionsFrom: aCollection 
       
   196     ^ aCollection
       
   197 
       
   198     "Created: / 29-10-2018 / 15:45:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   199 !
       
   200 
       
   201 selectPoolsFrom: aCollection
       
   202     ^ aCollection select:[:class | class isSharedPool ]
       
   203 
       
   204     "Created: / 29-10-2018 / 15:45:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   184 ! !
   205 ! !
   185 
   206 
   186 !BeeProjectWriter methodsFor:'source writing'!
   207 !BeeProjectWriter methodsFor:'source writing'!
   187 
   208 
   188 fileOut:packageID on:aStream
   209 fileOut:packageID on:aStream
   189     | projectDefinitionClass revinfo classesToFileout methodsToFileOut |
   210     | projectDefinitionClass revinfo classes extensions |
   190 
   211 
   191     projectDefinitionClass := packageID asPackageId projectDefinitionClass.
   212     projectDefinitionClass := packageID asPackageId projectDefinitionClass.
   192     classesToBeInitialized := OrderedCollection new.
   213     classesToBeInitialized := OrderedCollection new.
   193 
   214 
       
   215     name := projectDefinitionClass name.
       
   216     writer project: name.
       
   217     description := projectDefinitionClass description.  
       
   218 
   194     revinfo := projectDefinitionClass revisionInfo.
   219     revinfo := projectDefinitionClass revisionInfo.
   195     name := projectDefinitionClass name.
   220     revinfo notNil ifTrue:[ 
   196     version := revinfo revision.
   221         version := revinfo revision.
   197     author := revinfo author asString.
   222         author := revinfo author asString.
   198     timestamp := Timestamp fromDate: revinfo date andTime: revinfo time.
   223         timestamp := Timestamp fromDate: (Date readFrom: revinfo date) andTime: (Time readFrom: revinfo time).
   199     description := projectDefinitionClass description.  
   224     ] ifFalse:[ 
       
   225         version := Timestamp now printString.
       
   226         author := UserPreferences current historyManagerSignature.
       
   227         timestamp := Timestamp now.
       
   228     ].
       
   229 
   200 
   230 
   201     aStream lineEndCRLF.
   231     aStream lineEndCRLF.
   202 
   232 
   203     "/ make sure that everything is loaded.
   233     "/ make sure that everything is loaded.
   204     projectDefinitionClass notNil ifTrue:[
   234     projectDefinitionClass notNil ifTrue:[
   205         projectDefinitionClass autoload.
   235         projectDefinitionClass autoload.
   206         projectDefinitionClass ensureFullyLoaded.
   236         projectDefinitionClass ensureFullyLoaded.
   207         classesToFileout := Smalltalk allClassesInPackage:packageID.
   237         classes := Smalltalk allClassesInPackage:packageID.
   208     ] ifFalse:[
   238     ] ifFalse:[
   209         classesToFileout := Smalltalk allClassesInPackage:packageID.
   239         classes := Smalltalk allClassesInPackage:packageID.
   210         classesToFileout := classesToFileout collect:[:each | each autoload].
   240         classes := classes collect:[:each | each autoload].
   211     ].
   241     ].
   212 
   242 
   213     methodsToFileOut := projectDefinitionClass extensions.
   243     extensions := projectDefinitionClass extensionMethods.
   214 
       
   215     self activityNotification:'checking for unportable unicode...'.
       
   216 
   244 
   217     self fileOutHeaderOn:aStream.
   245     self fileOutHeaderOn:aStream.
   218     self fileOutClasses: classesToFileout on: aStream.
   246     self fileOutPools: (self selectPoolsFrom:classes) on:  aStream. 
   219     self fileOutExtensions: methodsToFileOut on: aStream.
   247     self fileOutClasses: (self selectClassesFrom:classes) on: aStream.
       
   248     self fileOutExtensions: (self selectExtensionsFrom:extensions) on: aStream.
   220     self fileOutFooterOn: aStream.
   249     self fileOutFooterOn: aStream.
   221 
   250 
   222     "Created: / 14-04-2015 / 13:42:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   251     "Created: / 14-04-2015 / 13:42:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   223     "Modified: / 07-09-2016 / 14:34:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   252     "Modified: / 30-10-2018 / 14:43:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   224 !
   253 !
   225 
   254 
   226 fileOutClasses:arg1 on:arg2
   255 fileOutClasses:arg1 on:arg2
   227     "raise an error: must be redefined in concrete subclass(es)"
   256     "raise an error: must be redefined in concrete subclass(es)"
   228 
   257 
   242 
   271 
   243 fileOutHeaderOn:arg
   272 fileOutHeaderOn:arg
   244     "raise an error: must be redefined in concrete subclass(es)"
   273     "raise an error: must be redefined in concrete subclass(es)"
   245 
   274 
   246     ^ self subclassResponsibility
   275     ^ self subclassResponsibility
       
   276 !
       
   277 
       
   278 fileOutPools: pools on: stream
       
   279     ^ self subclassResponsibility
       
   280 
       
   281     "Created: / 29-10-2018 / 15:40:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   282 ! !
       
   283 
       
   284 !BeeProjectWriter class methodsFor:'documentation'!
       
   285 
       
   286 version_HG
       
   287 
       
   288     ^ '$Changeset: <not expanded> $'
   247 ! !
   289 ! !
   248 
   290 
   249 
   291 
   250 BeeProjectWriter initialize!
   292 BeeProjectWriter initialize!