[squeak-dev] The Trunk: Tools-mt.1085.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Thu Dec 9 09:27:12 UTC 2021


For the folks that have a substantial interest in using traits for their projects, here is an example view from Squot (i.e. our Git Browser):





Since this perspective on classes-and-traits is rather tool-specific, there is no interface in SystemNavigation for that. You can already see that a simple tree is not sufficient to integrate both classes and their traits at the same time.

Personally, I think that one should try looking for a nice architecture without using traits. Smalltalk tools are sufficient to find protocols that cross-cut the primary decomposition, that is, the class hierarchy. ;o) In Vivide, I added a few traits to document the interface that is necessary to build new visualizations. A simple dummy visualization would have done the same.

Best,
Marcel
Am 09.12.2021 10:12:45 schrieb commits at source.squeak.org <commits at source.squeak.org>:
Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1085.mcz

==================== Summary ====================

Name: Tools-mt.1085
Author: mt
Time: 9 December 2021, 10:12:31.310176 am
UUID: a5c416d3-2818-4a46-abfb-7c524be90692
Ancestors: Tools-mt.1084

Complements an earlier change in HierarchyBrowser to show traits in a hierarchy. Now, for classes, also show the traits they use along with their superclasses.

=============== Diff against Tools-mt.1084 ===============

Item was added:
+ ----- Method: HierarchyBrowser>>allAncestorsOfClass:withLevelDo: (in category 'hierarchy - classes') -----
+ allAncestorsOfClass: class withLevelDo: classAndLevelBlock
+
+ self
+ allAncestorsOfClass: class
+ withLevelDo: classAndLevelBlock
+ startingLevel: 1.!

Item was added:
+ ----- Method: HierarchyBrowser>>allAncestorsOfClass:withLevelDo:startingLevel: (in category 'hierarchy - classes') -----
+ allAncestorsOfClass: class withLevelDo: classAndLevelBlock startingLevel: level
+
+ (class superclass ifNil: [#()] ifNotNil: [:c | {c}]), class traits
+ do: [:ancestor |
+ ancestor isTrait
+ ifTrue: [
+ self
+ allAncestorsOfTrait: ancestor
+ withLevelDo: classAndLevelBlock
+ startingLevel: level + 1]
+ ifFalse: [
+ self
+ allAncestorsOfClass: ancestor
+ withLevelDo: classAndLevelBlock
+ startingLevel: level + 1].
+ classAndLevelBlock value: ancestor value: level].!

Item was changed:
+ ----- Method: HierarchyBrowser>>allAncestorsOfTrait:withLevelDo: (in category 'hierarchy - traits') -----
- ----- Method: HierarchyBrowser>>allAncestorsOfTrait:withLevelDo: (in category 'traits') -----
allAncestorsOfTrait: trait withLevelDo: traitAndLevelBlock

self
allAncestorsOfTrait: trait
withLevelDo: traitAndLevelBlock
startingLevel: 1.!

Item was changed:
+ ----- Method: HierarchyBrowser>>allAncestorsOfTrait:withLevelDo:startingLevel: (in category 'hierarchy - traits') -----
- ----- Method: HierarchyBrowser>>allAncestorsOfTrait:withLevelDo:startingLevel: (in category 'traits') -----
allAncestorsOfTrait: trait withLevelDo: traitAndLevelBlock startingLevel: level

trait traitComposition asTraitComposition traits
do: [:ancestor |
self
allAncestorsOfTrait: ancestor
withLevelDo: traitAndLevelBlock
startingLevel: level + 1.
traitAndLevelBlock value: ancestor value: level].!

Item was added:
+ ----- Method: HierarchyBrowser>>allSuccessorsOfClass:withLevelDo:startingLevel: (in category 'hierarchy - classes') -----
+ allSuccessorsOfClass: class withLevelDo: classAndLevelBlock startingLevel: level
+
+ classAndLevelBlock value: class value: level.
+ (class subclasses sorted: #name ascending)
+ do: [:successor |
+ self
+ allSuccessorsOfClass: successor
+ withLevelDo: classAndLevelBlock
+ startingLevel: level + 1].!

Item was changed:
+ ----- Method: HierarchyBrowser>>allSuccessorsOfTrait:withLevelDo:startingLevel: (in category 'hierarchy - traits') -----
- ----- Method: HierarchyBrowser>>allSuccessorsOfTrait:withLevelDo:startingLevel: (in category 'traits') -----
allSuccessorsOfTrait: trait withLevelDo: traitAndLevelBlock startingLevel: level

traitAndLevelBlock value: trait value: level.
+ (trait users "includes classes and traits" sorted: #name ascending)
- (trait users sorted: #name ascending)
do: [:user |
self
allSuccessorsOfTrait: user
withLevelDo: traitAndLevelBlock
startingLevel: level + 1].!

Item was changed:
+ ----- Method: HierarchyBrowser>>defineClass:notifying: (in category 'hierarchy - classes') -----
- ----- Method: HierarchyBrowser>>defineClass:notifying: (in category 'class functions') -----
defineClass: defString notifying: aController

super defineClass: defString notifying: aController.
self updateAfterClassChange.!

Item was changed:
+ ----- Method: HierarchyBrowser>>defineTrait:notifying: (in category 'hierarchy - traits') -----
- ----- Method: HierarchyBrowser>>defineTrait:notifying: (in category 'traits') -----
defineTrait: defString notifying: aController

super defineTrait: defString notifying: aController.
self updateAfterClassChange.!

Item was changed:
+ ----- Method: HierarchyBrowser>>initHierarchyForClass: (in category 'hierarchy - classes') -----
- ----- Method: HierarchyBrowser>>initHierarchyForClass: (in category 'initialization') -----
initHierarchyForClass: aClassOrMetaClass
+
+ | nonMetaClass baseLevel |
- | nonMetaClass superclasses |
centralClass := aClassOrMetaClass.
nonMetaClass := aClassOrMetaClass theNonMetaClass.
self selectEnvironment: aClassOrMetaClass environment.
metaClassIndicated := aClassOrMetaClass isMeta.
classDisplayList := OrderedCollection new.
+ baseLevel := 0.
+ self
+ allAncestorsOfClass: nonMetaClass
+ withLevelDo: [ : each : level | baseLevel := baseLevel max: level ].
+ self
+ allAncestorsOfClass: nonMetaClass
+ withLevelDo:
+ [ : classOrTrait : level | | label |
+ label := (String streamContents:
+ [:stream | baseLevel - level timesRepeat: [ stream nextPutAll: ' ' ].
+ stream nextPutAll: classOrTrait name ]).
+ classOrTrait isTrait
+ ifTrue: [ label := label asText addAttribute: TextEmphasis italic ].
+ classDisplayList add: label ].
+ self
+ allSuccessorsOfClass: nonMetaClass
+ withLevelDo:
+ [ : each : level | classDisplayList add:
- (superclasses := nonMetaClass allSuperclasses reversed) withIndexDo:
- [ : each : indent | classDisplayList add:
- (String streamContents:
- [ : stream | indent - 1 timesRepeat: [ stream nextPutAll: ' ' ].
- stream nextPutAll: each name ]) ].
- nonMetaClass
- allSubclassesWithLevelDo:
- [ : eachClass : lvl | classDisplayList add:
(String streamContents:
+ [ : stream | level timesRepeat: [ stream nextPutAll: ' ' ].
+ stream nextPutAll: each name ]) ]
+ startingLevel: baseLevel.
- [ : stream | lvl timesRepeat: [ stream nextPutAll: ' ' ].
- stream nextPutAll: eachClass name ]) ]
- startingLevel: superclasses size.

self changed: #classList.
+ self selectClass: nonMetaClass.!
- self selectClass: nonMetaClass!

Item was changed:
+ ----- Method: HierarchyBrowser>>initHierarchyForTrait: (in category 'hierarchy - traits') -----
- ----- Method: HierarchyBrowser>>initHierarchyForTrait: (in category 'traits') -----
initHierarchyForTrait: baseTraitOrClassTrait

| baseTrait baseLevel |
centralClass := baseTraitOrClassTrait.
baseTrait := baseTraitOrClassTrait baseTrait.
self selectEnvironment: baseTraitOrClassTrait environment.
metaClassIndicated := baseTraitOrClassTrait isClassTrait.
classDisplayList := OrderedCollection new.
baseLevel := 0.
self
allAncestorsOfTrait: baseTrait
+ withLevelDo: [ : each : level | baseLevel := baseLevel max: level ].
- withLevelDo: [:each :level | baseLevel := baseLevel max: level].
self
allAncestorsOfTrait: baseTrait
withLevelDo:
[:each :level | classDisplayList add:
(String streamContents:
[ : stream | baseLevel - level timesRepeat: [ stream nextPutAll: ' ' ].
stream nextPutAll: each name ]) ].
self
allSuccessorsOfTrait: baseTrait
withLevelDo:
+ [:classOrTrait :level | | label |
+ label := (String streamContents:
- [:each :level | classDisplayList add:
- (String streamContents:
[ : stream | level timesRepeat: [ stream nextPutAll: ' ' ].
+ stream nextPutAll: classOrTrait name ]).
+ classOrTrait isTrait
+ ifFalse: [ label := label asText addAttribute: TextEmphasis italic ].
+ classDisplayList add: label ]
- stream nextPutAll: each name ]) ]
startingLevel: baseLevel.

self changed: #classList.
self selectClass: baseTrait.!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211209/73bc449a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 87964 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211209/73bc449a/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 54042 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211209/73bc449a/attachment-0003.png>


More information about the Squeak-dev mailing list