Method implementation finder and analyzer for Pharo Smalltalk...
Find and analyze method implementations across class hierarchies to understand abstract methods, implementation patterns, and assess refactoring opportunities.
Use this skill to:
1. Find implementors → search_implementors(method_name)
2. Get source code → get_method_source(class, method)
3. Analyze patterns → Compare implementations
4. Apply learnings → Use discovered idioms in your code
When to use: Implementing a method for the first time and want to follow conventions.
Quick workflow:
1. search_implementors("methodName")
2. Sample 5-10 well-known classes
3. get_method_source for each
4. Identify common pattern
5. Apply to your implementation
Common idioms:
hash → Combine fields with bitXor:initialize → Call super initialize first= → Check class equality, then compare fieldsprintOn: → Use class identifier + element printingExample: Learning hash implementation
Point>>hash → "^ x hash bitXor: y hash"
Association>>hash → "^ key hash bitXor: value hash"
Pattern: field1 hash bitXor: field2 hash
When to use: Planning to change a method signature or refactor implementations.
Quick workflow:
1. Count implementors: search_implementors(method)
2. Count references: search_references(method)
3. Assess impact: Low (<5 impl, <20 refs) / Medium (5-20, 20-100) / High (20+, 100+)
4. Decide: Proceed / Add new method / Don't change
Example: Changing at:put:
Implementors: 50+ classes
References: 500+ call sites
Impact: VERY HIGH
Decision: Don't change. Add new method instead.
When to use: Suspect multiple classes have identical implementations.
Quick workflow:
1. Find implementors in same hierarchy
2. Get source for each
3. Compare for duplicates
4. Refactor identical code to superclass
Example: Consolidating isEmpty
Array>>isEmpty → "^ self size = 0"
Set>>isEmpty → "^ self size = 0"
OrderedCollection>>isEmpty → "^ self size = 0"
Action: Pull up to Collection superclass
When to use: Encountering self subclassResponsibility and need to see concrete implementations.
Quick workflow:
1. Check abstract definition in superclass
2. Find all implementors
3. Study 3-5 concrete implementations
4. Understand expected behavior
Example: Understanding Collection>>do:
Collection>>do: → "self subclassResponsibility"
Array>>do: → "1 to: self size do: [:i | aBlock value: (self at: i)]"
LinkedList>>do: → "[node notNil] whileTrue: [aBlock value: node value. ...]"
Understanding: Each uses its own iteration strategy
When to use: Finding references to a specific class's implementation, not all implementations.
Quick workflow:
1. Find implementors
2. Find all references
3. Filter by receiver type/context
4. Focus on relevant usage
Example: Finding Collection>>select: usage (not Dictionary>>select:)
Implementors: [Collection, Dictionary, Interval, ...]
References: 1000+ call sites
Filter by variable context:
"myArray select: [...]" → Collection implementation
"myDict select: [...]" → Dictionary implementation
mcp__smalltalk-interop__search_implementors: 'methodName'
Returns all classes implementing the method.
mcp__smalltalk-interop__get_method_source: class: 'ClassName' method: 'methodName'
Gets source code for a specific implementation.
mcp__smalltalk-interop__eval: 'Collection allSubclasses'
Useful for scoping analysis to specific hierarchies.
mcp__smalltalk-interop__search_references: 'methodName'
Finds all senders (combines well with implementor analysis).
| Goal | Tools | Pattern |
|---|---|---|
| Learn idiom | search_implementors → get_method_source | Sample 5-10, identify pattern |
| Assess impact | search_implementors + search_references | Count both, assess risk |
| Find duplicates | search_implementors → get_method_source | Compare, find identical |
| Narrow usage | search_implementors → search_references | Filter by receiver type |
eval("ClassA allSubclasses")Problem: Need to implement printOn: in new class
1. search_implementors("printOn:")
2. Filter to similar classes
3. get_method_source for 3-5 examples
4. Identify pattern
5. Apply to your class
Problem: Want to change at:put: signature
1. search_implementors("at:put:") → Count implementations
2. search_references("at:put:") → Count call sites
3. Assess impact (High/Medium/Low)
4. Decide: Change / Add new / Don't change
Problem: Suspect duplicate isEmpty implementations
1. search_implementors("isEmpty")
2. Focus on Collection hierarchy
3. get_method_source for subclasses
4. Compare for identical code
5. Refactor to superclass if identical
For comprehensive analysis techniques and real-world scenarios, see:
Key principle: Implementations across a hierarchy reveal design patterns and idioms. Use them to write better, more idiomatic code.
Primary workflow: Find implementors → Get source → Analyze patterns → Apply learnings
Remember: Always scope your analysis to relevant hierarchies and representative classes to avoid information overload.