Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1019.mcz ==================== Summary ==================== Name: Tools-mt.1019 Author: mt Time: 11 December 2020, 10:30:43.719926 am UUID: bdc455f1-6d58-4dc1-8c2f-5f6b3a9765d4 Ancestors: Tools-mt.1018 Makes inspector for character sets more useful. See: http://forum.world.st/The-Trunk-Tools-mt-1018-mcz-td5125215.html Adds two extensions to the inspector framework: - truncated field streaming now provides object and index if needed (via #cull:) - representation of indices in collections can be overwritten via #elementNameAt: (like #elementGetterAt: and #elementSetterAt:) Note that the character-set inspector is the first collection inspector that uses its contents as keys/indices. Even the set inspector was simplier, because its internal array could be exposed. Also note that the elements of CharacterSetComplement and LazyCharacterSet cannot be shown as they are not enumerable. =============== Diff against Tools-mt.1018 =============== Item was added: + ----- Method: CharacterSetInspector>>characterNameFor: (in category 'private') ----- + characterNameFor: character + "Extracted from Character >> #printOn:." + + ^ String streamContents: [:stream | | integerValue | + ((integerValue := character asInteger) > 32 and: [integerValue ~= 127]) + ifTrue: [ + character printAsLiteralOn: stream. + stream space]. + stream nextPut: $(; print: integerValue; nextPut: $)].! Item was added: + ----- Method: CharacterSetInspector>>characterValueFor: (in category 'private') ----- + characterValueFor: character + "Extracted from Character >> #printOn: (and #storeOn:)." + + ^ String streamContents: [:stream | + (character class constantNameFor: character) + ifNotNil: [:name | stream nextPutAll: character class name; space; nextPutAll: name] + ifNil: [stream nextPutAll: character class name; nextPutAll: ' value: '; print: character asInteger]].! Item was added: + ----- Method: CharacterSetInspector>>elementAt: (in category 'menu - private') ----- + elementAt: indexOrKey + "All field keys are characters." + + ^ indexOrKey! Item was changed: ----- Method: CharacterSetInspector>>elementGetterAt: (in category 'private') ----- + elementGetterAt: character - elementGetterAt: element + self shouldNotImplement.! - ^ [:set | element]! Item was changed: ----- Method: CharacterSetInspector>>elementIndices (in category 'private') ----- elementIndices + self shouldNotImplement.! - ^ self object canBeEnumerated - ifTrue: [self object asArray] - ifFalse: [#()]! Item was added: + ----- Method: CharacterSetInspector>>elementNameAt: (in category 'private') ----- + elementNameAt: index + + self shouldNotImplement.! Item was changed: ----- Method: CharacterSetInspector>>elementSetterAt: (in category 'private') ----- elementSetterAt: index + self shouldNotImplement.! - ^ [:set :element | self error: 'Character sets cannot be changed.']! Item was added: + ----- Method: CharacterSetInspector>>streamElementsOn: (in category 'fields - streaming') ----- + streamElementsOn: aStream + "Overwritten to realize array representation of character sets if they can be enumerated. Assume that enumeration is deterministic." + + self object canBeEnumerated ifFalse: [^ self]. + + self + streamOn: aStream + truncate: self object asArray "Requires character set to be enumerable." + collectFields: [:character :index | + (self newFieldForType: #element key: index) + name: ('{1}: {2}' format: {index. self characterNameFor: character}); + valueGetter: [:characterSet | self characterValueFor: character]; printValueAsIs; + yourself]! Item was added: + ----- Method: CollectionInspector>>elementNameAt: (in category 'private') ----- + elementNameAt: index + + ^ index printString! Item was changed: ----- Method: CollectionInspector>>streamElementsOn: (in category 'fields - streaming') ----- streamElementsOn: aStream "Create a field for each element in the collection. Use the index' #printString (and not #asString) to reveal the nature of the key, which are usually integers (1, 2, 3, ...), but can be symbols (#apple, #tree, ...) or other objects (aMorph, aSocket, ...) in dictionary-like collections. Maybe #storeString would be even better but can be very expensive to compute." self streamOn: aStream truncate: self elementIndices collectFields: [:index | (self newFieldForType: #element key: index) + name: (self elementNameAt: index); - name: index printString; valueGetter: (self elementGetterAt: index); valueSetter: (self elementSetterAt: index); yourself]! Item was changed: ----- Method: Inspector>>streamOn:truncate:collectFields:ellipsisFrom: (in category 'fields - truncation') ----- streamOn: aStream truncate: someObjects collectFields: fieldBlock ellipsisFrom: ellipsisBlock "Create fields for someObjects using fieldBlock. Using the current #truncationLimit, create an extra ellipsis field to hide objects that go beyond this limit." (someObjects size <= self truncationLimit or: [self truncationLimit < 0]) + ifTrue: [^ aStream nextPutAll: (someObjects withIndexCollect: [:each :index | fieldBlock cull: each cull: index])]. - ifTrue: [^ aStream nextPutAll: (someObjects collect: [:each | fieldBlock value: each])]. + someObjects readStream in: [:readStream | | offset | + offset := readStream size - self truncationTail. - someObjects readStream in: [:readStream | aStream nextPutAll: ((readStream next: self truncationLimit - self truncationTail - 1) + withIndexCollect: [:each :index | fieldBlock cull: each cull: index]); + nextPut: (ellipsisBlock value: (readStream upToPosition: offset)); - collect: [:each | fieldBlock value: each]); - nextPut: (ellipsisBlock value: (readStream upToPosition: readStream size - self truncationTail)); nextPutAll: (readStream upToEnd + withIndexCollect: [:each :index | fieldBlock cull: each cull: index + offset])].! - collect: [:each | fieldBlock value: each])].! |
|
Like.
> On 2020-12-11, at 1:32 AM, Marcel Taeumel <[hidden email]> wrote: > > <image.png> >> Am 11.12.2020 10:30:56 schrieb [hidden email] <[hidden email]>: >> >> Marcel Taeumel uploaded a new version of Tools to project The Trunk: >> http://source.squeak.org/trunk/Tools-mt.1019.mcz >> >> ==================== Summary ==================== >> >> Name: Tools-mt.1019 >> Author: mt >> Time: 11 December 2020, 10:30:43.719926 am >> UUID: bdc455f1-6d58-4dc1-8c2f-5f6b3a9765d4 >> Ancestors: Tools-mt.1018 >> >> Makes inspector for character sets more useful. See: http://forum.world.st/The-Trunk-Tools-mt-1018-mcz-td5125215.html tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Strange OpCodes: SBB: Store in Bit Bucket |
Free forum by Nabble | Edit this page |