Molding Spotter searches
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 GtSpotterStart
. For example, GtSpotterStart>>#gtSearchForPragmasFor:
defines the search of the pragmas from the image.
The method above defines the search through a fluent API, not unlike the Inspector views. Specifically, it uses the GtSpotterProtoSearch>>#list
.
Other methods, like GtSpotterStart>>#gtSearchForClassesFor:
which is responsible for searching for classes and traits in the image, rely on an explicit search. We use an explicit search because we want to delegate to a cache rather than traversing an existing list.
Examples
To learn from similar methods, you can look at Querying Pharo code with GT filters:
#gtSearch gtPragmas
Inspecting
Such search methods can be defined in any class and when Spotter is opened on an instance of the class, the custom search will become available. When a class defines a custom search, the inspector over an instance of that class will have a Spotter action button with the custom search.
For example, GtABAddressBook>>#gtGtSpotterForAddressesFor:
defines a search over the addresses from an address book. When inspecting an instance of GtABAddressBook
we get a search button in the inspector.