Hi folks. I will pay a beer in next ESUG to the person that helps me to refactor this piece of code of ImageSegments:
The idea is that I have a list of classes that were inactive and I want to group them by category (actually, seeing the code I think it is package) and to to create an ImageSegment per category (or package).
This is the code (ONLYYYYY a piece...I cut all the rest)
unused := self inactiveClassesDuringDiscovery.� "These are the classes that were not used"
��� groups := Dictionary new.
��� SystemOrganization categories do:
��� ��� [:cat |
��� ��� i := (cat findLast: [:c | c = $-]) - 1.
��� ��� i <= 0 ifTrue: [i := cat size].
��� ��� groups at: (cat copyFrom: 1 to: i)
��� ��� ��� put: (groups at: (cat copyFrom: 1 to: i) ifAbsent: [Array new]) ,
��� ��� ��� ((SystemOrganization superclassOrder: cat) select: [:c |
��� ��� ��� ��� unused includes: c]) asArray].
��� groups keys do:
��� ��� [:cat | roots := groups at: cat.
��� ��� Transcript cr; cr; show: cat; cr; print: roots; endEntry.
��� ��� roots := roots , (roots collect: [:c | c class]).
��� ��� "There seems to be a problem with these packages, thus they are excluded."
��� ��� ((cat beginsWith: 'Sys') or: [cat beginsWith: 'Multilingual'] or: [cat beginsWith: 'Kerne'] ) ifFalse:
��� ��� ��� [(ImageSegment new copyFromRoots: roots sizeHint: 0) extract;
��� ��� ��� ��� writeToFile: cat].
��� ��� Transcript cr; print: Smalltalk garbageCollect; endEntry]
Can someone help me tu rewrite this? I think I could use PackageOrganizer or PackageInfo� but I have no idea.
Thanks!
Mariano