In Pharo, String>>asClass
is a scripting convenience method that looks up a class based on its name. While in scripts it can be tolerated, using it in production code is an anti-pattern.
Stephane recently pointed out that some classes already exist in Glamour that make use of #asClass. For example:
GLMBrickStructureTrait>>openInBrickWindowLabeled: aLabel #GLMSystemWindowBrick asClassIfAbsent: [ ^ self asMorph openInWindow ]. ^ #GLMSystemWindowBrick asClass new ... openCenteredInWorld
This code should clearly not exist, but this is not what this post is about. The question is, how can we quickly find out where is String>>asClass
used inside Glamour.
Let’s use Spotter. We start from finding the String>>asClass
method.
We dive in (Cmd+RightArrow):
We see that there are 10 senders. To find those that are in Glamour, we simply filter by the GLM
prefix:
Quick and easy.