# HG changeset patch # User Claus Gittinger # Date 1364723521 -7200 # Node ID cce7b1ccaa6d8486da084c607be26d6b181e49a9 # Parent 454b05887d498743a2c0a46259574a88457f5cf9 class: InspectorView refactored fieldMenu: #localProtocolMenu #protocolMenu diff -r 454b05887d49 -r cce7b1ccaa6d InspectorView.st --- a/InspectorView.st Sat Mar 30 20:59:17 2013 +0100 +++ b/InspectorView.st Sun Mar 31 11:52:01 2013 +0200 @@ -1257,10 +1257,7 @@ - |items m sel protocolMenu localProtocolMenu - protocols protocolsSorted - selectorsByFirstCharacter alphaMenu - localSelectors| + |items m sel| sel := self selection. @@ -1363,74 +1360,6 @@ ]. ]. - protocols := Dictionary new. - selectorsByFirstCharacter := Dictionary new. - object class withAllSuperclassesDo:[:eachClass | - eachClass methodDictionary keysAndValuesDo:[:sel :m | - sel numArgs == 0 ifTrue:[ - (protocols at:m category ifAbsentPut:[Set new]) add:sel. - (selectorsByFirstCharacter at:(sel first asString) ifAbsentPut:[Set new]) add:sel. - ] - ]. - ]. - - protocolsSorted := protocols keys asArray sort. - protocolMenu := PopUpMenu - labels:#('alphabetical' '=') , protocolsSorted - selectors:#(nil nil) , protocolsSorted. - - protocolMenu - subMenuAt:'alphabetical' - put:[ - |firstChars| - - firstChars := selectorsByFirstCharacter keys asOrderedCollection sort. - alphaMenu := PopUpMenu - labels:firstChars - selector:#mmm - args:firstChars - receiver:self. - firstChars do:[:ch | - alphaMenu - subMenuAt:ch - put:[ - |selectors sortedSelectors| - - selectors := selectorsByFirstCharacter at:ch. - sortedSelectors := selectors asArray sort. - protocolMenu := PopUpMenu - labels:sortedSelectors - selector:#letSelectedObjectPerform: - args:sortedSelectors - receiver:self. - ] - ]. - alphaMenu - ]. - - protocolsSorted do:[:p | - protocolMenu - subMenuAt:p - put:[ - |selectors sortedSelectors| - - selectors := protocols at:p. - sortedSelectors := selectors asArray sort. - protocolMenu := PopUpMenu - labels:sortedSelectors - selector:#letSelectedObjectPerform: - args:sortedSelectors - receiver:self. - ] - ]. - - localSelectors := object class methodDictionary keys asArray sort. - localProtocolMenu := PopUpMenu - labels:localSelectors - selector:#letSelectedObjectPerform: - args:localSelectors - receiver:self. - items := items , (self sortOrderItems). items := items , (self numberBaseItems). @@ -1438,8 +1367,8 @@ itemList:items resources:resources. - m subMenuAt:#protocolMenu put:protocolMenu. - m subMenuAt:#localProtocolMenu put:localProtocolMenu. + m subMenuAt:#protocolMenu put:(self protocolMenu). + m subMenuAt:#localProtocolMenu put:(self localProtocolMenu). (self theSingleSelectionIndex isNil) ifTrue:[ m disableAll:#(doFollow doInspect doBasicInspect doNewInspect @@ -1463,11 +1392,30 @@ m disable:#browseMethodsClass ]. + sel := nil. "/ release ref to sel; helps reference finder + ^ m "Modified: / 20-07-2012 / 10:50:45 / cg" ! +localProtocolMenu + "return the menu for the inspected object's local implemented messages" + + |localSelectors labels localProtocolMenu| + + localSelectors := object class methodDictionary keys asArray sort. + "/ kludge: '-' and '=' are special in a menu + labels := localSelectors collect:[:sel | (#('-' '=') includes:sel) ifTrue:[' ',sel] ifFalse:[sel]]. + localProtocolMenu := PopUpMenu + labels:labels + selector:#letSelectedObjectPerform: + args:localSelectors + receiver:self. + + ^ localProtocolMenu +! + numberBaseItems ^ { #('-') . @@ -1595,6 +1543,74 @@ ^ #() ! +protocolMenu + "return the menu for the inspected object's implemented messages" + + |protocols protocolsSorted selectorsByFirstCharacter protocolMenu| + + protocols := Dictionary new. + selectorsByFirstCharacter := Dictionary new. + object class withAllSuperclassesDo:[:eachClass | + eachClass methodDictionary keysAndValuesDo:[:sel :m | + sel numArgs == 0 ifTrue:[ + (protocols at:m category ifAbsentPut:[Set new]) add:sel. + (selectorsByFirstCharacter at:(sel first asString) ifAbsentPut:[Set new]) add:sel. + ] + ]. + ]. + + protocolsSorted := protocols keys asArray sort. + protocolMenu := PopUpMenu + labels:#('alphabetical' '=') , protocolsSorted + selectors:#(nil nil) , protocolsSorted. + + protocolMenu + subMenuAt:'alphabetical' + put:[ + |firstChars alphaMenu| + + firstChars := selectorsByFirstCharacter keys asOrderedCollection sort. + alphaMenu := PopUpMenu + labels:firstChars + selector:#mmm + args:firstChars + receiver:self. + firstChars do:[:ch | + alphaMenu + subMenuAt:ch + put:[ + |selectors sortedSelectors| + + selectors := selectorsByFirstCharacter at:ch. + sortedSelectors := selectors asArray sort. + PopUpMenu + labels:sortedSelectors + selector:#letSelectedObjectPerform: + args:sortedSelectors + receiver:self. + ] + ]. + alphaMenu + ]. + + protocolsSorted do:[:p | + protocolMenu + subMenuAt:p + put:[ + |selectors sortedSelectors| + + selectors := protocols at:p. + sortedSelectors := selectors asArray sort. + PopUpMenu + labels:sortedSelectors + selector:#letSelectedObjectPerform: + args:sortedSelectors + receiver:self. + ] + ]. + ^ protocolMenu +! + sortOrderItems object class instSize == 0 ifTrue:[ ^ #() ]. ^ { @@ -3489,10 +3505,10 @@ !InspectorView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.301 2013-03-26 11:18:01 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.302 2013-03-31 09:52:01 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.301 2013-03-26 11:18:01 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/InspectorView.st,v 1.302 2013-03-31 09:52:01 cg Exp $' ! !