Tobias Pape uploaded a new version of Tools to project The Trunk: http://source.squeak.org/trunk/Tools-topa.721.mcz
==================== Summary ====================
Name: Tools-topa.721 Author: topa Time: 29 November 2016, 3:27:14.942944 pm UUID: 2d64a7b9-8dcb-46fd-9371-c9dcb3f9cfd1 Ancestors: Tools-mt.720
Accessor generation.
Makes for a nice class hook and pushes responsibility to the class.
=============== Diff against Tools-mt.720 ===============
Item was added: + ----- Method: Behavior>>createGetterFor: (in category '*Tools-Browser-accessors') ----- + createGetterFor: aName + + | code | + code := '{1}\ <generated>\ ^ {1}' withCRs format: {aName.}. + self compile: code classified: #accessing notifying: nil.!
Item was added: + ----- Method: Behavior>>createInstVarAccessors (in category '*Tools-Browser-accessors') ----- + createInstVarAccessors + "Create getters and setters for all inst vars defined here, + except do NOT clobber or override any selectors already understood by me" + + self instVarNames + collect: [:each | each asSymbol] + thenDo: [:instVar | + (self canUnderstand: instVar) ifFalse: [self createGetterFor: instVar]. + (self canUnderstand: instVar asMutator) ifFalse: [self createSetterFor: instVar]]. + + !
Item was added: + ----- Method: Behavior>>createSetterFor: (in category '*Tools-Browser-accessors') ----- + createSetterFor: aName + + | code | + code := '{1}: anObject\ <generated>\ {2}{1} := anObject.' withCRs + format: {aName. self settersReturnValue ifTrue: ['^ '] ifFalse: [''].}. + self compile: code classified: #accessing notifying: nil.!
Item was changed: ----- Method: Browser>>createInstVarAccessors (in category 'class functions') ----- createInstVarAccessors - "Create getters and setters for all inst vars defined at the level of the current class selection, - except do NOT clobber or override any selectors already understood by the instances of the selected class"
+ self selectedClassOrMetaClass + ifNotNil: [:aClass | aClass createInstVarAccessors]. + ! - self selectedClassOrMetaClass ifNotNil: - [:aClass| | cr | - cr := String with: Character cr. - aClass instVarNames do: - [:aName | | newMessage setter | - (aClass canUnderstand: aName asSymbol) ifFalse: - [newMessage := - aName, cr, cr, - ' ^ ', aName. - aClass compile: newMessage classified: #accessing notifying: nil]. - (aClass canUnderstand: (setter := aName, ':') asSymbol) ifFalse: - [newMessage := - setter, ' anObject', cr, cr, - (aClass settersReturnValue ifTrue: [' ^'] ifFalse: [' ']), - aName, ' := anObject'. - aClass compile: newMessage classified: #accessing notifying: nil]]]!
packages@lists.squeakfoundation.org