--- a/Workspace.st Tue Feb 02 23:15:57 2016 +0100
+++ b/Workspace.st Tue Feb 02 23:37:44 2016 +0100
@@ -1962,14 +1962,27 @@
('-' )
('CommentIt' commentSelection CommentSelection )
('UncommentIt' uncommentSelection UncommentSelection ))
- resources:resources
- after:#'indent'.
+ resources:resources
+ after:#'indent'.
+ subsub
+ addItemList:#(
+ ('Inspect Instances' inspectInstances nil)
+ )
+ resources:resources
+
+ after:#inspectString.
+
+ (self hasSelection not
+ or:[ (sel := self selectionAsString asSymbolIfInterned) isNil
+ or:[ (Smalltalk at:sel) isBehavior not ]]) ifTrue:[
+ sub disable:#inspectInstances
+ ].
].
self hasSelection ifFalse:[
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt
browseReferencesToIt timeIt spyOnIt
- browseSharedPoolOfIt browseIt).
+ browseSharedPoolOfIt browseIt inspectInstances).
self supportsSyntaxElements ifTrue:[
self syntaxElementForSelectorUnderCursor notNil ifTrue:[
sub enableAll:#(browseImplementorsOfIt browseSendersOfIt )
@@ -2089,6 +2102,24 @@
"Modified: / 20-12-2011 / 11:22:20 / cg"
!
+inspectInstances
+ |nameOfVariable cls insts|
+
+ nameOfVariable := self selectedTextOrSyntaxElement.
+ nameOfVariable isEmptyOrNil ifTrue:[^ self].
+ nameOfVariable := nameOfVariable asSymbolIfInterned.
+ nameOfVariable isNil ifTrue:[^ self].
+ cls := Smalltalk at:nameOfVariable.
+ cls isNil ifTrue:[^ self].
+ cls isBehavior ifFalse:[^ self].
+ insts := cls allInstances.
+ insts isEmpty ifTrue:[
+ Dialog information:(resources string:'No instances of %1' with:nameOfVariable).
+ ^ self.
+ ].
+ insts inspect.
+!
+
inspectIt
"user selected 'inspectIt' from menu; use doIt to evaluate the code
and start an inspector on the result"