Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pharo/Squeak - How do I quickly browse the implementation of a given method in a given class?

Let's say I want to see how "copy" is implemented in the Dictionary class. Currently I use the system browser and manually traverse the inheritance hierarchy (bottom up) until I find the class that implements the given message. Is there a one-liner for the workspace, that would open the system browser at the right location?

like image 465
Janus Troelsen Avatar asked Feb 29 '12 00:02

Janus Troelsen


4 Answers

( SomeClass whichClassIncludesSelector: #initialize ) browse

That will browse the class that implements the message #initialize.

like image 182
Jorge Ressia Avatar answered Oct 19 '22 02:10

Jorge Ressia


Personally, I just type the #selector in a workspace, highlight it, and hit alt+m to pull up all implementors of the message. Much faster than typing all that code.

like image 28
Ramon Leon Avatar answered Oct 19 '22 01:10

Ramon Leon


(SomeClass>>#someSelector) browse

works as well in my Pharo image.

works as well in my Pharo image. And since you want to find a class first, you can combine it with previous example..

((SomeSubclass whichClassIncludesSelector: #someSelector)>>#someSelector) browse

to directly go to given method.

like image 2
Igor Stasenko Avatar answered Oct 19 '22 01:10

Igor Stasenko


If you are using OmniBrowser, you can use the contextual menu Implementors in Hierarchy... to only browse the implementors of a selector in the hierarchy of the Dictionary.

OmniBrowser also provides an Inheritance Browser. Select any implementation of #copy and click on the Inheritance button in the toolbar. It will show you a hierarchical view of all implementors of #copy.

like image 2
Lukas Renggli Avatar answered Oct 19 '22 02:10

Lukas Renggli