4.4.4 Browsing
- Q How do I find/browse all sends to super?
- A Two alternatives:
SystemNavigation default browseAllSelect: [:method | method sendsToSuper ]
SystemNavigation default browseMethodsWithSourceString: 'super'
- Q How do I browse all super sends within a hierarchy?
- A The old way:
class := Collection.
SystemNavigation default
browseMessageList: (class withAllSubclasses gather: [ :each |
each methodDict associations
select: [ :assoc | assoc value sendsToSuper ]
thenCollect: [ :assoc | MethodReference class: each selector: assoc key ] ])
name: 'Supersends of ' , class name , ' and its subclasses'
The refactoring browser way:
((BrowserEnvironment new forClasses: (Collection withAllSubclasses))
selectMethods: [:method | method sendsToSuper])
open
- Q How do I find out which are the new methods implemented in a class (i.e., not overridden or extended)?
- A Example:
Integer
[:aClass| aClass methodDict keys select: [:aMethod |
(aClass superclass canUnderstand: aMethod) not ]] value: Integer
- Q How do I tell which methods are abstract?
- A
[:aClass| aClass methodDict keys select: [:aMethod |
(aClass>>aMethod) isAbstract ]] value: Number
- Q How do I find all the Traits in the system?
- A
Smalltalk allTraits
- Q How do I find which classes use traits?
- A
Smalltalk allClasses select: [:each | each hasTraitComposition ]
- Q How do I browse messages sent but not implemented?
- A
SystemNavigation default browseAllUnimplementedCalls
Also Smalllint: open > code critics on a category will do it.