Tuesday, April 28, 2009

Seeing all available methods for a class.

One of the biggest questions I had was how to see all methods available in a class, including inherited methods.

Turns out you can get such a list programatically with SomeClass allSelectors. but that turns out to be overwhelming because base classes like Object and Morph have so many methods. (RectangleMorph allSelectors. returns an IdentitySet with 2560 members.)

But it's much nicer to use a tool, and that's what the Protocol Browser is for.

To load a Protocol Browser, right-click the class name in the normal browser, and select "browse protocol". It shows you all methods in nice little categories (protocols), and there's also a "limit" button that lets you filter out anything above a certain ancestor class. (By default, it filters out Object).

One problem: if you're using OmniBrowser in squeak 3.10, then when you click on the protocol name, you get a big nasty error. I made a patch for this, though. You can get the patch by going to the OB-Standard package in the Monticello Browser and merging in OB-Standard-mjw.405.mcz from http://source.wiresong.ca/ob/. (See my last post for a walkthrough on how to merge.

No comments:

Post a Comment