Hi-
When I create methods using the Debugger's 'Create' button I am never
sure which categories are used in the class I'm adding the method to
versus those in its super classes. In an effort to not have to think
about that any more I've adapted the
ClassDescription>>#allMethodCategoriesIntegratedThrough: to put the
method categories that are used in the target class first, then those in
the super classes after that.
I think this should work in Pharo and Squeak but I've only tested it in
Pharo 1.4. I've attached a changeset and also pasted the method below
Paul
allMethodCategoriesIntegratedThrough: mostGenericClass
"Answer a list of all the method categories of the receiver and all its
superclasses, up through mostGenericClass"
| otherClassCategories thisClassCategories combinedClassCategories |
otherClassCategories := OrderedCollection new.
self allSuperclasses
do: [ :aClass |
(aClass includesBehavior: mostGenericClass)
ifTrue: [ otherClassCategories addAll: aClass organization
categories ] ].
otherClassCategories remove: 'no messages' asSymbol ifAbsent: [ ].
thisClassCategories := self organization categories asSortedCollection:
[ :a :b | a asLowercase < b asLowercase ].
^ Array
streamContents: [ :stream |
stream
nextPutAll: thisClassCategories;
nextPutAll:
((otherClassCategories asSet removeAllSuchThat: [ :each |
thisClassCategories includes: each ])
asSortedCollection: [ :a :b | a asLowercase < b asLowercase ]) ]
'From Pharo1.4 of 18 April 2012 [Latest update: #14457] on 1 November 2012 at
1:29:30 pm'!
!ClassDescription methodsFor: 'accessing method dictionary' stamp:
'PaulDeBruicker 11/1/2012 13:18'!
allMethodCategoriesIntegratedThrough: mostGenericClass
"Answer a list of all the method categories of the receiver and all its
superclasses, up through mostGenericClass"
| otherClassCategories thisClassCategories combinedClassCategories |
otherClassCategories := OrderedCollection new.
self allSuperclasses
do: [ :aClass |
(aClass includesBehavior: mostGenericClass)
ifTrue: [ otherClassCategories addAll: aClass
organization categories ] ].
otherClassCategories remove: 'no messages' asSymbol ifAbsent: [ ].
thisClassCategories := self organization categories asSortedCollection:
[ :a :b | a asLowercase < b asLowercase ].
^ Array
streamContents: [ :stream |
stream
nextPutAll: thisClassCategories;
nextPutAll:
((otherClassCategories asSet
removeAllSuchThat: [ :each | thisClassCategories includes: each ])
asSortedCollection: [ :a :b | a asLowercase < b asLowercase ]) ]! !