Reputation: 5394
Newbie here, going through "Pharo by Example". The book mentions an example of EllipseMorph new openInWorld
result in a call to Morph openInWorld
, while EllipseMorph defaultColor
is an overridden message: how do I figure this out using the System Browser or something else?
The usual find method way only finds matches in the immediately selected class. Is it possible in general to lookup which class will respond to (say) Foo bar
?
Update: Thanks for all the suggestions (Finder, Spotter); the Debugger is the most eye-opening of the tools I've encountered yet!
Upvotes: 4
Views: 786
Reputation: 15917
Smalltalk offers lots of tools and browsers that can help you with this. If you already know the name of the message, you can:
In this case you could also type EllipseMorph new openInWorld
in a playground and select Debug-It from the menu. That will open a debugger with the selection on new
. If you click on into, the top line changes to EllipseMorph class(Behavior) new
. That indicates that the new
from Behavior
is used here. If you continue stepping with into (2 times), you'll see it change to EllipseMorph(BorderedMorph) initialize
. By just following the trace of messages sent, you can see where everything is implemented.
Upvotes: 5
Reputation: 4958
To add to Stephan's answer (+1), one of the easiest ways, especially if you're new to Smalltalk and prefer using the GUI, is to use the Finder tool. Just left-click anywhere on the background (the equivalent of your desktop in your Pharo image) and select Tools > Finder
:
Next, type the name of the method, e.g. openInWorld
in the search field (make sure "Selectors" is selected in the drop-down to the right) and hit Enter:
You can then browse all methods containing your search string (notice it's automatically a wildcard search) and the classes implementing them. The panel at the bottom shows you selected implementations, and the context menu gives you a few more options, e.g. browsing the class you selected.
Upvotes: 5