[squeak-dev] Browse all senders within class categories [snippet]
Ross Boylan
RossBoylan at stanfordalumni.org
Fri Sep 3 19:29:01 UTC 2010
In case this is useful to others, here's some code I've been using to
find all senders of message within a given category.
It's implemented on SystemDictionary.
browseCallsOn: aLiteral category: aCategory
"Show all senders of aLiteral in classes with category prefix aCategory"
"Smalltalk browseCallsOn: #fork category: 'OSProcess'."
"This omits some refinements as seen in, e.g., #allCallsOn:"
|myClasses myMethods|
myClasses := OrderedCollection new.
(Utilities classCategoriesStartingWith: aCategory) do: [:cat |
myClasses addAll: (SystemOrganization listAtCategoryNamed: cat).
].
myClasses := myClasses collect: [:c | self classNamed: c].
myClasses addAll: (myClasses collect: [:c | c class "we want class methods as well as instance methods"]).
myMethods := OrderedCollection new.
myClasses do: [:myClass |
( myClass whichSelectorsReferTo: aLiteral) do: [:sel |
myMethods add: (
MethodReference new
setStandardClass: myClass
methodSymbol: sel
).
].
].
self browseMessageList: myMethods
name: 'senders of ', aLiteral asString, ' in ', aCategory asString, ' package'
autoSelect: aLiteral.
I ran this in Cuis 2.6, though I think it should work in other images.
Note that Cuis lacks PackageInfo, which Levente Uzonyi used in a
2010-04-12 posting that provides something similar in spirit.
I suspect this is too special purpose to be added to the standard image.
If you use it in a workspace or as a method off Utilies, change self to
Smalltalk.
Comments welcome.
Ross Boylan
More information about the Squeak-dev
mailing list
|