"Bill Schwab" <
[hidden email]> wrote in message
news:cv0uf6$12ni$
[hidden email]...
> Hello all,
>
>> I see how to file out methods (Migrate does it with the safe/dangerous
>> selector stuff), but it looks a little complicated.
>
> Having an example to follow, it was trivial (see below). I doubt it would
> be so obvious trying it from scratch. Any takers for a cleanup, or is it
> good enough as is?
In D6 we have the method I've pasted below. This groups the methods by class
for efficiency and a repeatable ordering, which is useful when using
traditional file based source code control systems. I believe it was
extracted from the package systems file out of loose methods.
Regards
Blair
----------------
!SourceFiler methodsFor!
fileOutMethods: aCollection
"Append the definitions of the methods in the <collection> argument to the
source stream,
ordered by class. Any method category settings are included."
| methodsByClass |
methodsByClass := Dictionary new.
aCollection do:
[:each |
"Note that the selectors will be filed out in sorted order, so we don't
need to sort them"
(methodsByClass at: each methodClass ifAbsentPut: [OrderedCollection
new]) add: each selector].
(methodsByClass associations
asSortedCollection: [:a :b | (a key name trueCompare: b key name) <= 0])
do: [:each | self fileOutMessages: each value ofBehavior: each key]! !
!SourceFiler categoriesFor: #fileOutMethods:!public!source filing! !