Spotter is a universal search interface. Like in the case of the Inspector, we accomplish this through a moldable interface.
Search always happens in a context of an object. The default Spotter opens in a default context and can multiple kinds of searches like
Object, for a class or
./ for the local folder.
The actual search is defined separately. Each search definition has a name, and is presented in the search result in the form of a search category. Through this, every search yields results in possibly multiple categories of results. For example, in the default context we get:
A Spotter search is like an inspector view: it's a method implemented in a class of the object in the context of which we want to search. The global Spotter starts from an instance of
Object subclass: #GtSpotterStart
. This one has methods like
^ aSearch explicit
search: [ :aContext | GtPharoIndex current asyncClassesForWord: aContext searchQuery ];
"keyBinding: $b meta;"
which is responsible for searching for classes and traits in the image:
Such search methods can be defined in any class.
To learn from similar methods, you can look at Querying Pharo code: