If you have any thoughts on direction, I could take a look - I did the “dirty” and reimplemented the methods like everyone else… but it really felt like I shouldn’t have had to…
So my code looked a bit like this (where I should have used some sort of visitor with my stream instantiated, or maybe I could pass through some block, I think) (exercise solutionClasses asSortedCollection: [ :a :b | a name <= b name ]) do: [ :class | (exercise exercisePackage extendsClass: class) ifTrue: [ class exPrintOutExtensionsFor: exercise exercisePackage on: s ] ifFalse: [ class exPrintOutOn: s ] ] ]. And then in ClassDescription I had methods like this (noticed I need to visit the definition, the comments, the categories for class and instance etc.: exPrintOutOn: aWriteStream "Print a description of the receiver on aWriteStream." aWriteStream nextPutAll: '"-- #', self name, ' (class) --"'; cr; cr; nextPutAll: self definition; nextPut: $.; cr; cr. self hasComment ifTrue: [ aWriteStream nextPut: $". self comment trimBoth encodeDoublingDoubleQuotesOn: aWriteStream. aWriteStream nextPut: $"; cr; cr ]. self exPrintOutCategoriesFor: self class on: aWriteStream. self exPrintOutCategoriesFor: self on: aWriteStream > On 13 Jun 2019, at 08:26, Marcus Denker <marcus.den...@inria.fr> wrote: > > > >> On 19 May 2019, at 19:23, Tim Mackinnon <tim@testit.works> wrote: >> >> Hi - is there a way to iterate over all the code in a package (or class or >> baseline) in a generic way (to pretty print out class definitions, and >> methods - including extensions ). >> >> I was kind of hoping that with TonelWriter and Fileout and Critics that we >> would have a generic visitor mechanism but it seems that all of them just >> implemented it again - which misses a big opportunity for refactoring so >> that when you want to reason/print/manipulate code - it would be more >> straight forward. >> >> Is there anything/anyone addressing this ? Or maybe I’ve missed an obvious >> trick somewhere? >> > > I think we always wanted to add some default “visitor” style way of iterate > over the structure… > > I will add this higher on my priorities, because it actually should be quite > simple. > > > Marcus > >