4.4.4 Browsing

Q How do I find/browse all sends to super?
A Two alternatives:
  1. SystemNavigation default browseAllSelect: [:method | method sendsToSuper ]
  2. 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])
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?
[: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.

User Contributed Notes

intrader (11 October 2012, 4:24 pm)

BrowserEnvironment should be RBBrowserEnvironment

renggli (20 December 2011, 10:43 am)

1. The condition telling you if a method contains pragmas: aCompiledMethod pragmas isEmpty not.

2. The expression returning a collection of pragmas in a method: aCompiledMethod pragmas.

3. The expression opening a browser on all methods with pragmas: (RBBrowserEnvironment new selectMethods: [ :each | each pragmas isEmpty not ]) open.

daliot.oh (10 April 2011, 6:37 am)

How do I know whether a method contains pragmas?

How do I know what pragmas are present in a method?

How do I know all the existing pragmas in an image?

Add a Note

Licensed under Creative Commons BY-NC-SA | Published using Pier |