Inspector extension: Browse References to Instance Variable

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Inspector extension: Browse References to Instance Variable

Postby jkoepp » Mon Dec 15, 2008 1:47 am

To the context menu of the variables list of the inspector I added a new entry: "Browse References to Instance Variable". It uses the code from EtClassBrowser>>#stsInstanceVariableReferences.

So if you look at a selected variable in an inspector you know with one click which methods change and use the variable.

The code:

Code: Select all
   "from #stsInstanceVariableReferences"
   | failed value aClass varName theMethods |
   self isOneValueSelected ifFalse: [^self].
   failed := false.
   value := self retrieveValue: self selectedVariables first ifFail: [failed := true].
   failed ifTrue: [^self closeCorruptBrowser].
   aClass := self selectedVariables first reference object class.
   varName := self selectedVariables first reference name.
   self execShortOperation: [
      theMethods := aClass allMethodsReferencingInstVarName: varName.
      theMethods isEmpty
         ifTrue: [
            self owningImage message:
               ( ( NlsCatEMT  residentMsg: 'MxEMT351' )  bindWith: varName storeString)]  "$NLS$ No methods reference %1."
         ifFalse: [
            ((self browser: #highlightingMethods)
               on: theMethods
                  ( ( NlsCatEMT  residentMsg: 'MxEMT6' )  bindWith: varName)  "$NLS$ References to %1"
               highlighting: varName)
                  owningImage: self owningImage; 
                  open] ]

and for the menu e.g.

Code: Select all
   "Answer the variables list menu."

   | menu |
   (menu := super variablesMenu)
      add: #browseReferencesToInstanceVariable
         label: 'Browse References to Instance Variable'
         enable: [self dirty not and: [self selectedVariables size = 1 and: [self selectedVariables first reference class = DbgNamedInstVarReference]]]
         after: #browseHierarchy;

I use this in a subclass of StsInspector and I love it!

Posts: 9
Joined: Mon Mar 31, 2008 4:40 am

Re: Inspector extension: Browse References to Instance Variable

Postby tc » Wed Dec 17, 2008 1:02 pm


We discussed this in our weekly meeting and I opened case 38388. The cases are simply a way to keep track these requests.

Posts: 304
Joined: Tue Oct 17, 2006 7:40 am
Location: Raleigh, NC

Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest