MethodFinderWindow.st
changeset 1525 c91fbd9f8338
parent 1522 f67b97bc683a
child 1526 8e62e3f56402
equal deleted inserted replaced
1524:4efbd088b787 1525:c91fbd9f8338
     6 		arg3BoxVisible argCountHolder argCountList argument1Editor
     6 		arg3BoxVisible argCountHolder argCountList argument1Editor
     7 		argument2Editor argument3Editor argument4Editor resultSelected
     7 		argument2Editor argument3Editor argument4Editor resultSelected
     8 		lookAtResultEditor'
     8 		lookAtResultEditor'
     9 	classVariableNames:''
     9 	classVariableNames:''
    10 	poolDictionaries:''
    10 	poolDictionaries:''
    11 	category:'MethodFinder-James'
    11 	category:'MethodFinder'
    12 !
    12 !
    13 
    13 
    14 
    14 
    15 !MethodFinderWindow class methodsFor:'interface specs'!
    15 !MethodFinderWindow class methodsFor:'interface specs'!
    16 
    16 
    34         #name: #windowSpec
    34         #name: #windowSpec
    35         #window: 
    35         #window: 
    36        #(#WindowSpec
    36        #(#WindowSpec
    37           #label: 'MethodFinder'
    37           #label: 'MethodFinder'
    38           #name: 'MethodFinder'
    38           #name: 'MethodFinder'
    39           #min: #(#Point 10 10)
    39           #min: #(#Point nil nil)
    40           #max: #(#Point 1280 1024)
    40           #max: #(#Point nil nil)
    41           #bounds: #(#Rectangle 16 47 818 718)
    41           #bounds: #(#Rectangle 16 47 566 447)
       
    42           #menu: #menu
       
    43           #forceRecursiveBackground: false
    42         )
    44         )
    43         #component: 
    45         #component: 
    44        #(#SpecCollection
    46        #(#SpecCollection
    45           #collection: #(
    47           #collection: #(
    46            #(#ComboListSpec
       
    47               #name: 'allowedArgments'
       
    48               #layout: #(#LayoutFrame 0 0.201912 4 0 0 0.364397 22 0)
       
    49               #model: #argCountHolder
       
    50               #comboList: #argCountList
       
    51               #useIndex: true
       
    52             )
       
    53            #(#ActionButtonSpec
       
    54               #label: 'Search'
       
    55               #name: 'Button1'
       
    56               #layout: #(#LayoutFrame 0 0.426523 132 0 0 0.575866 154 0)
       
    57               #translateLabel: true
       
    58               #tabable: true
       
    59               #model: #search
       
    60             )
       
    61            #(#ActionButtonSpec
       
    62               #label: 'Clear'
       
    63               #name: 'Button2'
       
    64               #layout: #(#LayoutFrame 0 0.258065 132 0 0 0.407407 154 0)
       
    65               #translateLabel: true
       
    66               #model: #clear
       
    67             )
       
    68            #(#SequenceViewSpec
    48            #(#SequenceViewSpec
    69               #name: 'List1'
    49               #name: 'List1'
    70               #layout: #(#LayoutFrame 0 0 161 0 0 0.6 0 0.5)
    50               #layout: #(#LayoutFrame 0 0 0 0.5 0 0.7 0 1)
    71               #hasHorizontalScrollBar: true
    51               #hasHorizontalScrollBar: true
    72               #hasVerticalScrollBar: true
    52               #hasVerticalScrollBar: true
    73               #autoHideScrollBars: true
    53               #autoHideScrollBars: true
    74               #valueChangeSelector: #updateImplementorsOf:
    54               #valueChangeSelector: #updateImplementorsOf:
    75               #useIndex: true
    55               #useIndex: true
    76               #sequenceList: #resultHolder
    56               #sequenceList: #resultHolder
    77             )
    57             )
    78            #(#SequenceViewSpec
    58            #(#SequenceViewSpec
    79               #name: 'List2'
    59               #name: 'List2'
    80               #layout: #(#LayoutFrame 0 0.6 0 0 0 1 0 0.5)
    60               #layout: #(#LayoutFrame 0 0.65 0 0 0 1 0 1)
    81               #hasHorizontalScrollBar: true
    61               #hasHorizontalScrollBar: true
    82               #hasVerticalScrollBar: true
    62               #hasVerticalScrollBar: true
    83               #autoHideScrollBars: true
    63               #autoHideScrollBars: true
    84               #doubleClickSelector: #openBrowserOn:
    64               #doubleClickSelector: #openBrowserOn:
    85               #useIndex: false
    65               #useIndex: false
    86               #sequenceList: #classOfResultHolder
    66               #sequenceList: #classOfResultHolder
    87             )
    67             )
    88            #(#HorizontalPanelViewSpec
    68            #(#ViewSpec
    89               #name: 'HorizontalPanel1'
    69               #name: 'Box4'
    90               #layout: #(#LayoutFrame 6 0 26 0 0 0.6 129 0)
    70               #layout: #(#LayoutFrame 0 0 0 0 0 0.65 0 0.43)
    91               #horizontalLayout: #fit
       
    92               #verticalLayout: #fit
       
    93               #horizontalSpace: 3
       
    94               #verticalSpace: 3
       
    95               #component: 
    71               #component: 
    96              #(#SpecCollection
    72              #(#SpecCollection
    97                 #collection: #(
    73                 #collection: #(
    98                  #(#WorkspaceSpec
    74                  #(#LabelSpec
    99                     #name: 'ReceiverEditor'
    75                     #label: 'Reciever'
   100                     #tabable: true
    76                     #name: 'RecieverLabel'
   101                     #hasHorizontalScrollBar: false
    77                     #layout: #(#LayoutFrame -4 0.0162791 7 0 -4 0.293023 18 0)
   102                     #hasVerticalScrollBar: false
    78                     #translateLabel: true
   103                     #autoHideScrollBars: true
    79                     #adjust: #left
   104                     #extent: #(#Point 156 103)
       
   105                     #postBuildCallback: #receiverWidgetCreated:
       
   106                   )
    80                   )
   107                  #(#VerticalPanelViewSpec
    81                  #(#ComboListSpec
   108                     #name: 'VerticalPanel1'
    82                     #name: 'allowedArgments'
       
    83                     #layout: #(#LayoutFrame 0 0.339535 2 0 0 0.653488 19 0)
       
    84                     #model: #argCountHolder
       
    85                     #comboList: #argCountList
       
    86                     #useIndex: true
       
    87                   )
       
    88                  #(#LabelSpec
       
    89                     #label: 'MessageAnswer'
       
    90                     #name: 'MessageAnswerLabel'
       
    91                     #layout: #(#LayoutFrame 0 0.6693 5 0 0 0.99023 17 0)
       
    92                     #translateLabel: true
       
    93                     #adjust: #left
       
    94                   )
       
    95                  #(#HorizontalPanelViewSpec
       
    96                     #name: 'HorizontalPanel1'
       
    97                     #layout: #(#LayoutFrame 0 0 20 0 0 1 0 1)
   109                     #horizontalLayout: #fit
    98                     #horizontalLayout: #fit
   110                     #verticalLayout: #fit
    99                     #verticalLayout: #fit
   111                     #horizontalSpace: 3
   100                     #horizontalSpace: 3
   112                     #verticalSpace: 3
   101                     #verticalSpace: 3
   113                     #component: 
   102                     #component: 
   114                    #(#SpecCollection
   103                    #(#SpecCollection
   115                       #collection: #(
   104                       #collection: #(
   116                        #(#ViewSpec
   105                        #(#WorkspaceSpec
   117                           #name: 'Box1'
   106                           #name: 'ReceiverEditor'
   118                           #visibilityChannel: #arg1BoxVisible
   107                           #tabable: true
       
   108                           #hasHorizontalScrollBar: false
       
   109                           #hasVerticalScrollBar: false
       
   110                           #autoHideScrollBars: true
       
   111                           #extent: #(#Point 117 152)
       
   112                           #postBuildCallback: #receiverWidgetCreated:
       
   113                         )
       
   114                        #(#VerticalPanelViewSpec
       
   115                           #name: 'VerticalPanel1'
       
   116                           #horizontalLayout: #fit
       
   117                           #verticalLayout: #fit
       
   118                           #horizontalSpace: 3
       
   119                           #verticalSpace: 3
   119                           #component: 
   120                           #component: 
   120                          #(#SpecCollection
   121                          #(#SpecCollection
   121                             #collection: #(
   122                             #collection: #(
   122                              #(#WorkspaceSpec
   123                              #(#ViewSpec
   123                                 #name: 'Arg1Editor'
   124                                 #name: 'Box1'
   124                                 #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   125                                 #visibilityChannel: #arg1BoxVisible
   125                                 #tabable: true
   126                                 #component: 
   126                                 #hasHorizontalScrollBar: false
   127                                #(#SpecCollection
   127                                 #hasVerticalScrollBar: false
   128                                   #collection: #(
   128                                 #autoHideScrollBars: true
   129                                    #(#WorkspaceSpec
   129                                 #postBuildCallback: #argument1WidgetCreated:
   130                                       #name: 'Arg1Editor'
       
   131                                       #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   132                                       #tabable: true
       
   133                                       #hasHorizontalScrollBar: false
       
   134                                       #hasVerticalScrollBar: false
       
   135                                       #autoHideScrollBars: true
       
   136                                       #postBuildCallback: #argument1WidgetCreated:
       
   137                                     )
       
   138                                    )
       
   139                                  
       
   140                                 )
       
   141                                 #extent: #(#Point 117 49)
       
   142                               )
       
   143                              #(#ViewSpec
       
   144                                 #name: 'Box2'
       
   145                                 #visibilityChannel: #arg2BoxVisible
       
   146                                 #component: 
       
   147                                #(#SpecCollection
       
   148                                   #collection: #(
       
   149                                    #(#WorkspaceSpec
       
   150                                       #name: 'TextEditor5'
       
   151                                       #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   152                                       #tabable: true
       
   153                                       #hasHorizontalScrollBar: false
       
   154                                       #hasVerticalScrollBar: false
       
   155                                       #autoHideScrollBars: true
       
   156                                       #postBuildCallback: #argument2WidgetCreated:
       
   157                                     )
       
   158                                    )
       
   159                                  
       
   160                                 )
       
   161                                 #extent: #(#Point 117 48)
       
   162                               )
       
   163                              #(#ViewSpec
       
   164                                 #name: 'Box3'
       
   165                                 #visibilityChannel: #arg3BoxVisible
       
   166                                 #component: 
       
   167                                #(#SpecCollection
       
   168                                   #collection: #(
       
   169                                    #(#WorkspaceSpec
       
   170                                       #name: 'TextEditor6'
       
   171                                       #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   172                                       #tabable: true
       
   173                                       #hasHorizontalScrollBar: false
       
   174                                       #hasVerticalScrollBar: false
       
   175                                       #autoHideScrollBars: true
       
   176                                       #postBuildCallback: #argument3WidgetCreated:
       
   177                                     )
       
   178                                    )
       
   179                                  
       
   180                                 )
       
   181                                 #extent: #(#Point 117 49)
   130                               )
   182                               )
   131                              )
   183                              )
   132                            
   184                            
   133                           )
   185                           )
   134                           #extent: #(#Point 156 32)
   186                           #extent: #(#Point 117 152)
   135                         )
   187                         )
   136                        #(#ViewSpec
   188                        #(#WorkspaceSpec
   137                           #name: 'Box2'
   189                           #name: 'AnswerEditor'
   138                           #visibilityChannel: #arg2BoxVisible
   190                           #tabable: true
   139                           #component: 
   191                           #hasHorizontalScrollBar: false
   140                          #(#SpecCollection
   192                           #hasVerticalScrollBar: false
   141                             #collection: #(
   193                           #autoHideScrollBars: true
   142                              #(#WorkspaceSpec
   194                           #extent: #(#Point 118 152)
   143                                 #name: 'TextEditor5'
   195                           #postBuildCallback: #messageAnswerWidgetCreated:
   144                                 #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   145                                 #tabable: true
       
   146                                 #hasHorizontalScrollBar: false
       
   147                                 #hasVerticalScrollBar: false
       
   148                                 #autoHideScrollBars: true
       
   149                                 #postBuildCallback: #argument2WidgetCreated:
       
   150                               )
       
   151                              )
       
   152                            
       
   153                           )
       
   154                           #extent: #(#Point 156 33)
       
   155                         )
       
   156                        #(#ViewSpec
       
   157                           #name: 'Box3'
       
   158                           #visibilityChannel: #arg3BoxVisible
       
   159                           #component: 
       
   160                          #(#SpecCollection
       
   161                             #collection: #(
       
   162                              #(#WorkspaceSpec
       
   163                                 #name: 'TextEditor6'
       
   164                                 #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   165                                 #tabable: true
       
   166                                 #hasHorizontalScrollBar: false
       
   167                                 #hasVerticalScrollBar: false
       
   168                                 #autoHideScrollBars: true
       
   169                                 #postBuildCallback: #argument3WidgetCreated:
       
   170                               )
       
   171                              )
       
   172                            
       
   173                           )
       
   174                           #extent: #(#Point 156 32)
       
   175                         )
   196                         )
   176                        )
   197                        )
   177                      
   198                      
   178                     )
   199                     )
   179                     #extent: #(#Point 156 103)
       
   180                   )
       
   181                  #(#WorkspaceSpec
       
   182                     #name: 'AnswerEditor'
       
   183                     #tabable: true
       
   184                     #hasHorizontalScrollBar: false
       
   185                     #hasVerticalScrollBar: false
       
   186                     #autoHideScrollBars: true
       
   187                     #extent: #(#Point 157 103)
       
   188                     #postBuildCallback: #messageAnswerWidgetCreated:
       
   189                   )
   200                   )
   190                  )
   201                  )
   191                
   202                
   192               )
   203               )
   193             )
   204             )
   194            #(#LabelSpec
   205            #(#ViewSpec
   195               #label: 'MessageAnswer'
   206               #name: 'Box5'
   196               #name: 'MessageAnswerLabel'
   207               #layout: #(#LayoutFrame 53 0.224737 0 0.44 0 0.65 0 0.495578)
   197               #layout: #(#LayoutFrame 325 0 2 0 475 0 25 0)
   208               #component: 
   198               #translateLabel: true
   209              #(#SpecCollection
   199               #adjust: #left
   210                 #collection: #(
   200             )
   211                  #(#ActionButtonSpec
   201            #(#LabelSpec
   212                     #label: 'Clear'
   202               #label: 'Reciever'
   213                     #name: 'Button2'
   203               #name: 'RecieverLabel'
   214                     #layout: #(#LayoutFrame 0 0 0 0 -5 0.5 0 1)
   204               #layout: #(#LayoutFrame 7 0 3 0 126 0 26 0)
   215                     #translateLabel: true
   205               #translateLabel: true
   216                     #model: #clear
   206               #adjust: #left
   217                   )
   207             )
   218                  #(#ActionButtonSpec
   208            #(#WorkspaceSpec
   219                     #label: 'Search'
   209               #name: 'TextEditor4'
   220                     #name: 'Button1'
   210               #layout: #(#LayoutFrame 0 0 0 0.5 0 1 0 1)
   221                     #layout: #(#LayoutFrame 5 0.5 0 0 0 1 0 1)
   211               #model: #provideHelpComment
   222                     #translateLabel: true
   212               #hasHorizontalScrollBar: true
   223                     #tabable: true
   213               #hasVerticalScrollBar: true
   224                     #model: #search
   214             )
   225                   )
   215            #(#WorkspaceSpec
   226                  )
   216               #name: 'Workspace1'
   227                
   217               #layout: #(#LayoutFrame 0 0 0 0.5 0 0.5 0 1)
   228               )
   218               #model: #resultSelected
       
   219               #hasHorizontalScrollBar: true
       
   220               #hasVerticalScrollBar: true
       
   221               #postBuildCallback: #lookAtResultEditor:
       
   222             )
   229             )
   223            )
   230            )
   224          
   231          
   225         )
   232         )
   226       )
   233       )
   227 ! !
   234 ! !
   228 
   235 
       
   236 !MethodFinderWindow class methodsFor:'menu specs'!
       
   237 
       
   238 menu
       
   239     "This resource specification was automatically generated
       
   240      by the MenuEditor of ST/X."
       
   241 
       
   242     "Do not manually edit this!! If it is corrupted,
       
   243      the MenuEditor may not be able to read the specification."
       
   244 
       
   245     "
       
   246      MenuEditor new openOnClass:MethodFinderWindow andSelector:#menu
       
   247      (Menu new fromLiteralArrayEncoding:(MethodFinderWindow menu)) startUp
       
   248     "
       
   249 
       
   250     <resource: #menu>
       
   251 
       
   252     ^ 
       
   253      #(#Menu
       
   254         #(
       
   255          #(#MenuItem
       
   256             #label: '&File'
       
   257             #activeHelpKey: #file
       
   258             #submenu: 
       
   259            #(#Menu
       
   260               #(
       
   261                #(#MenuItem
       
   262                   #label: 'Exit'
       
   263                   #value: #closeRequest
       
   264                   #activeHelpKey: #fileExit
       
   265                 )
       
   266                )
       
   267               nil
       
   268               nil
       
   269             )
       
   270           )
       
   271          #(#MenuItem
       
   272             #label: 'Help'
       
   273             #startGroup: #right
       
   274             #submenu: 
       
   275            #(#Menu
       
   276               #(
       
   277                #(#MenuItem
       
   278                   #label: 'Documentation'
       
   279                   #value: #openHTMLDocumentation
       
   280                   #activeHelpKey: #helpTutorial
       
   281                 )
       
   282                #(#MenuItem
       
   283                   #label: 'About MenuEditor...'
       
   284                   #value: #openAboutThisApplication
       
   285                   #activeHelpKey: #aboutThisAppliaction
       
   286                 )
       
   287                )
       
   288               nil
       
   289               nil
       
   290             )
       
   291           )
       
   292          )
       
   293         nil
       
   294         nil
       
   295       )
       
   296 ! !
       
   297 
   229 !MethodFinderWindow methodsFor:'accessing'!
   298 !MethodFinderWindow methodsFor:'accessing'!
   230 
   299 
   231 receiver
   300 receiver
   232     "return the value of the instance variable 'receiver' (automatically generated)"
   301     "Return a copy of the value of the instance variable 'receiver' "
   233 
   302 
   234     ^ receiver copy
   303     ^ receiver copy
   235 ! !
   304 ! !
   236 
   305 
   237 !MethodFinderWindow methodsFor:'actions'!
   306 !MethodFinderWindow methodsFor:'actions'!
   238 
   307 
   239 argumentEditorsContents
   308 argumentEditorsContents
       
   309 
       
   310 "Determine how many text editors of the arguments are used and store the result
       
   311 as argCounter. The result being the minimum between how many editors have
       
   312 expressions in and how many are displayed.
       
   313 
       
   314 Add each argument string (key)and the evaluated version (value) to an Ordered Dictionary
       
   315 from each of the text editors.
       
   316 
       
   317 Return the OrderedDictionary with the expressions from all the text editors. "
       
   318 
   240      | tempArguments argCounter tempArgument1Editor tempArgument2Editor tempArgument3Editor tempArgument4Editor
   319      | tempArguments argCounter tempArgument1Editor tempArgument2Editor tempArgument3Editor tempArgument4Editor
   241 associationKey associationValue|
   320 associationKey associationValue|
   242 
   321 
   243 argCounter:=0.
   322 argCounter:=0.
   244 
   323 
   284 
   363 
   285 ^tempArguments
   364 ^tempArguments
   286 !
   365 !
   287 
   366 
   288 clear
   367 clear
   289     "automatically generated by UIPainter ..."
   368     "Reset the contents of all the outputs. Return the receiver."
   290 
       
   291     "*** the code below performs no action"
       
   292 
       
   293     "*** (except for some feedback on the Transcript)"
       
   294 
       
   295     "*** Please change as required and accept in the browser."
       
   296 
       
   297     "action to be added ..."
       
   298 
   369 
   299     receiverEditor contents:nil.
   370     receiverEditor contents:nil.
   300     argument1Editor contents:nil.
   371     argument1Editor contents:nil.
   301     argument2Editor contents:nil.
   372     argument2Editor contents:nil.
   302     argument3Editor contents:nil.
   373     argument3Editor contents:nil.
   303     messageAnswerEditor contents:nil.
   374     messageAnswerEditor contents:nil.
   304     self resultHolder value:nil.
   375     self resultHolder value:nil.
   305     Transcript showCR:self class name , ': action for reset ...'
   376     self classOfResultHolder value: nil.
   306 !
   377 !
   307 
   378 
   308 isExpression: aString
   379 isExpression: aString
   309 
   380       "Return true or false depending on if the subString includes certain characters"
   310 (aString includesSubString:': ') ifTrue:[^true].
   381 (aString includesSubString:': ') ifTrue:[^true].
   311 (aString includesSubString:'+') ifTrue:[^true].
   382 (aString includesSubString:'+') ifTrue:[^true].
   312 (aString includesSubString:'-') ifTrue:[^true].
   383 (aString includesSubString:'-') ifTrue:[^true].
   313 (aString includesSubString:'*') ifTrue:[^true].
   384 (aString includesSubString:'*') ifTrue:[^true].
   314 (aString includesSubString:'/') ifTrue:[^true].
   385 (aString includesSubString:'/') ifTrue:[^true].
   320 (aString includesSubString:'.') ifTrue:[^true].
   391 (aString includesSubString:'.') ifTrue:[^true].
   321 
   392 
   322  ^false
   393  ^false
   323 !
   394 !
   324 
   395 
   325 lookAtMessage:  anArgument
       
   326     "Opens browser on theArgument of a specific class. anArgument being a string with the
       
   327        Class and the selector upon which the browser is to be opened."
       
   328 
       
   329     |aClass aSelector x theArgument|
       
   330    self halt.
       
   331 
       
   332 
       
   333 !
       
   334 
       
   335 messageAnswerEditorContents
   396 messageAnswerEditorContents
       
   397    "Return a cleaned up version of message answer taken from the messageAnswerEditor
       
   398     as an association. The association has cleanedAnswerString as a key and the 
       
   399     compiledAnswer as value."
   336 
   400 
   337     |   aCleanedAnswerString   compiledAnswer  |
   401     |   aCleanedAnswerString   compiledAnswer  |
   338 
   402 
   339 aCleanedAnswerString:=self cleanInputs: (messageAnswerEditor contents). 
   403 aCleanedAnswerString:=self cleanInputs: (messageAnswerEditor contents). 
   340 
   404 
   345 ^aCleanedAnswerString->compiledAnswer.
   409 ^aCleanedAnswerString->compiledAnswer.
   346 !
   410 !
   347 
   411 
   348 openBrowserOn:anArgument 
   412 openBrowserOn:anArgument 
   349     "Opens browser on theArgument of a specific class. anArgument being a string with the
   413     "Opens browser on theArgument of a specific class. anArgument being a string with the
   350        Class and the selector upon which the browser is to be opened."
   414        Class and the selector upon which the browser is to be opened. Return the receiver."
   351 
   415 
   352     |aClass aSelector x theArgument|
   416     |aClass aSelector x theArgument|
   353 
   417 
   354     anArgument isNil ifTrue:[
   418     anArgument isNil ifTrue:[
   355 	^ self
   419         ^ self
   356     ].
   420     ].
   357     (anArgument at:1) == $* ifTrue:[
   421     (anArgument at:1) == $* ifTrue:[
   358 	theArgument := anArgument copyFrom:2
   422         theArgument := anArgument copyFrom:2
   359     ] ifFalse:[
   423     ] ifFalse:[
   360 	theArgument := anArgument
   424         theArgument := anArgument
   361     ].
   425     ].
   362     aClass := theArgument copyUpTo:(Character space).
   426     aClass := theArgument copyUpTo:(Character space).
   363     x := aClass size + 2.
   427     x := aClass size + 2.
   364     aSelector := theArgument copyFrom:x.
   428     aSelector := theArgument copyFrom:x.
   365     aClass := Smalltalk classNamed:aClass.
   429     aClass := Smalltalk classNamed:aClass.
   366     SystemBrowser openInClass:(aClass) selector:(aSelector asSymbol)    "/ Compiler evaluate: (aClass asSymbol). 
   430     SystemBrowser openInClass:(aClass) selector:(aSelector asSymbol)   
       
   431 
       
   432 "
       
   433 MethodFinderWindow new openBrowserOn: '*SmallInteger +'
       
   434 MethodFinderWindow new openBrowserOn: 'String ,'
       
   435 MethodFinderWindow new openBrowserOn: 'Number detentBy:atMultiplesOf:snap:' 
       
   436 
       
   437 
       
   438 "
   367 !
   439 !
   368 
   440 
   369 receiverEditorContents
   441 receiverEditorContents
       
   442    "Return a cleaned up version of receiver taken from the receiverEditor
       
   443     as an association. The association has aCleanedRecieverString as a key and the 
       
   444     compiledReceiver as value."
       
   445 
   370     |   aCleanedRecieverString   compiledReceiver  |
   446     |   aCleanedRecieverString   compiledReceiver  |
   371 
   447 
   372 aCleanedRecieverString:=self cleanInputs: (receiverEditor contents). 
   448 aCleanedRecieverString:=self cleanInputs: (receiverEditor contents). 
   373 
   449 
   374 compiledReceiver:=Compiler evaluate: aCleanedRecieverString.
   450 compiledReceiver:=Compiler evaluate: aCleanedRecieverString.
   377                         aCleanedRecieverString:=compiledReceiver printString].
   453                         aCleanedRecieverString:=compiledReceiver printString].
   378 ^aCleanedRecieverString->compiledReceiver.
   454 ^aCleanedRecieverString->compiledReceiver.
   379 !
   455 !
   380 
   456 
   381 search
   457 search
       
   458 "Do a search based on the input in the various text editors. Return the receiver."
   382 | tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf|
   459 | tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf|
   383 
       
   384 self resultHolder value: nil.               "reset the result list"
   460 self resultHolder value: nil.               "reset the result list"
   385 self classOfResultHolder value: nil.        "reset the implementorOf list"
   461 self classOfResultHolder value: nil.        "reset the implementorOf list"
   386 
   462 
   387 tempArguments:=self argumentEditorsContents.
   463 tempArguments:=self argumentEditorsContents.
   388 tempReceiver :=self receiverEditorContents .  
   464 tempReceiver :=self receiverEditorContents .  
   398 anArray at:1 put:receiverWithArgument;
   474 anArray at:1 put:receiverWithArgument;
   399         at:2 put: tempAnswer value.             
   475         at:2 put: tempAnswer value.             
   400 
   476 
   401 "an array now holds the following array #(#(receiver argument) answer) or #(#(reciever) answer). which should
   477 "an array now holds the following array #(#(receiver argument) answer) or #(#(reciever) answer). which should
   402 be suitable input for the method finder."
   478 be suitable input for the method finder."
   403 self halt.
       
   404 mf:= MethodFinder new.
   479 mf:= MethodFinder new.
   405 resultArray:= mf load: anArray; findMessage. 
   480 resultArray:= mf load: anArray; findMessage. 
   406 
   481 
   407 ((resultArray at:  1 )includesSubString: 'no single') ifTrue:[
   482 ((resultArray at:  1 )includesSubString: 'no single') ifTrue:[
   408                                 self warn: (resultArray at:  1 ).
   483                                 self warn: (resultArray at:  1 ).
   434 resultSelectors:= mf selectors.   "used to find implementors so we do not have to "
   509 resultSelectors:= mf selectors.   "used to find implementors so we do not have to "
   435 receiver:=tempReceiver            "search the string for the selector found. Stored as an ordered collection"
   510 receiver:=tempReceiver            "search the string for the selector found. Stored as an ordered collection"
   436 !
   511 !
   437 
   512 
   438 updateImplementorsOf:anInteger 
   513 updateImplementorsOf:anInteger 
   439     "  Request the implementors of the selected arguments "
   514     "Request the implementors of the selected argument provided by aNumber.
       
   515      Return the receiver. "
   440       |methods classList aNumber|
   516       |methods classList aNumber|
   441 
   517 
   442         self updateWorkSpace: anInteger .
   518 
   443        (anInteger isNil) ifTrue:[^self].
   519        (anInteger isNil) ifTrue:[^self].
   444       anInteger isNil ifTrue:[aNumber:=1]
   520       anInteger isNil ifTrue:[aNumber:=1]
   445                       ifFalse:[aNumber:=anInteger].  
   521                       ifFalse:[aNumber:=anInteger].  
   446       methods _ SystemBrowser findImplementorsOf: (resultSelectors at:aNumber) in:Smalltalk allClasses ignoreCase:false.
   522       methods:=SystemBrowser findImplementorsOf: (resultSelectors at:aNumber) in:Smalltalk allClasses ignoreCase:false.
   447       classList _ methods asOrderedCollection collect:[:m | m mclass name , ' ' , m selector].
   523       classList:=methods asOrderedCollection collect:[:m | m mclass name , ' ' , m selector].
   448 
   524 
   449       classList:=(self markMatchingClasses:(resultSelectors at:aNumber) classesWithSelector:classList).
   525       classList:=(self markMatchingClasses:(resultSelectors at:aNumber) classesWithSelector:classList).
   450 
   526 
   451     self classOfResultHolder value: classList.
   527     self classOfResultHolder value: classList.
   452 !
       
   453 
       
   454 updateWorkSpace: anInteger
       
   455 
       
   456 
       
   457       anInteger isNil ifTrue:[^self].
       
   458    resultSelected:= (self resultHolder value at:anInteger). 
       
   459         lookAtResultEditor replace:(resultSelected).
       
   460 ! !
   528 ! !
   461 
   529 
   462 !MethodFinderWindow methodsFor:'aspects'!
   530 !MethodFinderWindow methodsFor:'aspects'!
   463 
   531 
   464 arg1BoxVisible
   532 arg1BoxVisible
       
   533 "Determines if the box should be visble or not. Return true or false"
   465     arg1BoxVisible isNil ifTrue:[
   534     arg1BoxVisible isNil ifTrue:[
   466         arg1BoxVisible := BlockValue
   535         arg1BoxVisible := BlockValue
   467                               with:[:vh | vh value >= 2 ]
   536                               with:[:vh | vh value >= 2 ]
   468                               argument:(self argCountHolder)
   537                               argument:(self argCountHolder)
   469     ].
   538     ].
   470     ^ arg1BoxVisible.
   539     ^ arg1BoxVisible.
   471 !
   540 !
   472 
   541 
   473 arg2BoxVisible
   542 arg2BoxVisible
       
   543 "Determines if the box should be visble or not. Return true or false"
   474     arg2BoxVisible isNil ifTrue:[
   544     arg2BoxVisible isNil ifTrue:[
   475         arg2BoxVisible := BlockValue
   545         arg2BoxVisible := BlockValue
   476                               with:[:vh | vh value >= 3 ]
   546                               with:[:vh | vh value >= 3 ]
   477                               argument:(self argCountHolder)
   547                               argument:(self argCountHolder)
   478     ].
   548     ].
   479     ^ arg2BoxVisible.
   549     ^ arg2BoxVisible.
   480 !
   550 !
   481 
   551 
   482 arg3BoxVisible
   552 arg3BoxVisible
       
   553 "Determines if the box should be visble or not. Return true or false"
   483     arg3BoxVisible isNil ifTrue:[
   554     arg3BoxVisible isNil ifTrue:[
   484         arg3BoxVisible := BlockValue
   555         arg3BoxVisible := BlockValue
   485                               with:[:vh | vh value >= 4 ]
   556                               with:[:vh | vh value >= 4 ]
   486                               argument:(self argCountHolder)
   557                               argument:(self argCountHolder)
   487     ].
   558     ].
   488     ^ arg3BoxVisible.
   559     ^ arg3BoxVisible.
   489 !
   560 !
   490 
   561 
   491 arg4BoxVisible
   562 arg4BoxVisible
       
   563 "Determines if the box should be visble or not. Return true or false"
   492     arg4BoxVisible isNil ifTrue:[
   564     arg4BoxVisible isNil ifTrue:[
   493         arg4BoxVisible := BlockValue
   565         arg4BoxVisible := BlockValue
   494                               with:[:vh | vh value >= 5 ]
   566                               with:[:vh | vh value >= 5 ]
   495                               argument:(self argCountHolder)
   567                               argument:(self argCountHolder)
   496     ].
   568     ].
   497     ^ arg4BoxVisible.
   569     ^ arg4BoxVisible.
   498 !
   570 !
   499 
   571 
   500 argCountHolder
   572 argCountHolder
       
   573 "Return the value of argCounterHolder which is initialized at 2."
   501     argCountHolder isNil ifTrue:[
   574     argCountHolder isNil ifTrue:[
   502         argCountHolder := 2 asValue.
   575         argCountHolder := 2 asValue.
   503     ].     
   576     ].     
   504     ^ argCountHolder.
   577     ^ argCountHolder.
   505 !
   578 !
   506 
   579 
   507 argCountList
   580 argCountList
       
   581 "Return the argCountList"
   508     argCountList isNil ifTrue:[
   582     argCountList isNil ifTrue:[
   509         argCountList := #('0 arguments' '1 argument' '2 arguments' '3 arguments') asValue  
   583         argCountList := #('0 arguments' '1 argument' '2 arguments' '3 arguments') asValue  
   510     ].
   584     ].
   511     ^ argCountList.
   585     ^ argCountList.
   512 !
   586 !
   513 
   587 
   514 classOfResultHolder
   588 classOfResultHolder
   515     "Stores a valueHolder for "
   589     "Return a valueHolder which contains a collection with the names of the 
       
   590      implementors of a specific message.   "
   516 
   591 
   517     |holder|
   592     |holder|
   518 
       
   519     (holder := builder bindingAt:#classOfResultHolder) isNil ifTrue:[
   593     (holder := builder bindingAt:#classOfResultHolder) isNil ifTrue:[
   520 	holder := ValueHolder new.
   594         holder := ValueHolder new.
   521 	builder aspectAt:#classOfResultHolder put:holder
   595         builder aspectAt:#classOfResultHolder put:holder
   522     ].
   596     ].
   523     ^ holder
   597     ^ holder
   524 !
   598 !
   525 
   599 
   526 resultHolder
   600 resultHolder
   527     "automatically generated by UIPainter ..."
   601     "Return a value holder which contains the results of a search as a collection."
   528 
       
   529     "*** the code below creates a default model when invoked."
       
   530     "*** (which may not be the one you wanted)"
       
   531     "*** Please change as required and accept it in the browser."
       
   532     "*** (and replace this comment by something more useful ;-)"
       
   533 
   602 
   534     |holder|
   603     |holder|
   535 
       
   536     (holder := builder bindingAt:#resultHolder) isNil ifTrue:[
   604     (holder := builder bindingAt:#resultHolder) isNil ifTrue:[
   537 	holder := ValueHolder new.
   605         holder := ValueHolder new.
   538 	builder aspectAt:#resultHolder put:holder.
   606         builder aspectAt:#resultHolder put:holder.
   539 "/ if your app needs to be notified of changes, uncomment one of the lines below:
       
   540 "/        holder addDependent:self.
       
   541 "/        holder onChangeSend:#resultHolderChanged to:self.
       
   542     ].
   607     ].
   543     ^ holder.
   608     ^ holder.
   544 ! !
   609 ! !
   545 
   610 
   546 !MethodFinderWindow methodsFor:'callBacks'!
   611 !MethodFinderWindow methodsFor:'callBacks'!
   547 
   612 
   548 argument1WidgetCreated: aWidget
   613 argument1WidgetCreated: aWidget
       
   614 "Store the widget as an instance variable. Return the receiver"
       
   615 
       
   616 
   549         argument1Editor := aWidget scrolledView.
   617         argument1Editor := aWidget scrolledView.
   550 !
   618 !
   551 
   619 
   552 argument2WidgetCreated: aWidget
   620 argument2WidgetCreated: aWidget
       
   621 "Store the widget as an instance variable. Return the receiver"
       
   622 
   553 
   623 
   554         argument2Editor := aWidget scrolledView.
   624         argument2Editor := aWidget scrolledView.
   555 !
   625 !
   556 
   626 
   557 argument3WidgetCreated: aWidget
   627 argument3WidgetCreated: aWidget
       
   628 "Store the widget as an instance variable. Return the receiver"
       
   629 
   558 
   630 
   559         argument3Editor := aWidget scrolledView.
   631         argument3Editor := aWidget scrolledView.
   560 !
   632 !
   561 
   633 
   562 argumentsWidgetCreated: aWidget
       
   563 
       
   564         argumentsEditor := aWidget scrolledView.
       
   565 !
       
   566 
       
   567 lookAtResultEditor: aWidget
       
   568 
       
   569           lookAtResultEditor := aWidget scrolledView.
       
   570 !
       
   571 
       
   572 messageAnswerWidgetCreated: aWidget
   634 messageAnswerWidgetCreated: aWidget
   573 
   635 "Store the widget as an instance variable. Return the receiver"
   574 	messageAnswerEditor := aWidget scrolledView.
   636 
   575 !
   637         messageAnswerEditor := aWidget scrolledView.
   576 
   638 !
   577 provideHelpComment
   639 
   578  self halt.
   640 openHTMLDocumentation
   579 ^'test'
   641     HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#METHODFINDER'
   580 !
   642 !
   581 
   643 
   582 receiverWidgetCreated: aWidget
   644 receiverWidgetCreated: aWidget
       
   645 "Store the widget as an instance variable. Return the receiver"
   583 
   646 
   584         receiverEditor := aWidget scrolledView.
   647         receiverEditor := aWidget scrolledView.
   585 ! !
   648 ! !
   586 
   649 
   587 !MethodFinderWindow methodsFor:'controlInput'!
   650 !MethodFinderWindow methodsFor:'controlInput'!
   588 
   651 
   589 cleanInputs: aDirtyString
   652 cleanInputs: aDirtyString
   590         "Find an remove common mistakes.  Complain when ill formed."
   653      "Find and remove common mistakes made by the user. Return the 
       
   654      'aStringToBeCleaned' variable"
   591        | aStringToBeCleaned rs position|
   655        | aStringToBeCleaned rs position|
   592 
   656 
   593    aStringToBeCleaned:=aDirtyString.
   657    aStringToBeCleaned:=aDirtyString.
   594 
   658 
   595 (aStringToBeCleaned endsWith:(Character cr)) ifTrue:[
   659 (aStringToBeCleaned endsWith:(Character cr)) ifTrue:[
   616                         aStringToBeCleaned:=aStringToBeCleaned copyReplaceFrom: position to: position with: ''. "remove #"
   680                         aStringToBeCleaned:=aStringToBeCleaned copyReplaceFrom: position to: position with: ''. "remove #"
   617                         rs:=ReadStream on: aStringToBeCleaned.  ].
   681                         rs:=ReadStream on: aStringToBeCleaned.  ].
   618                    ^aStringToBeCleaned    
   682                    ^aStringToBeCleaned    
   619 !
   683 !
   620 
   684 
   621 markMatchingClasses
       
   622 	"If an example is used, mark classes matching the example instance with an asterisk."
       
   623 
       
   624 	| unmarkedClassList firstPartOfSelector receiverString receiver |
       
   625 
       
   626 	"Only 'example' queries can be marked."
       
   627 
       
   628 	unmarkedClassList _ resultSelectors copy.
       
   629 
       
   630 
       
   631 
       
   632 
       
   633 	unmarkedClassList do:
       
   634 		[:classAndMethod | | class |
       
   635 		class _ Compiler evaluate:
       
   636 				((ReadStream on: classAndMethod) upToAll: firstPartOfSelector).
       
   637 		(receiver class == class) ifTrue:
       
   638 			[resultSelectors add: '*', classAndMethod.
       
   639 			resultSelectors remove: classAndMethod]].
       
   640 
       
   641       resultSelectors sort:[:a :b | |rawA rawB|
       
   642 		    rawA := (a startsWith:'*') ifTrue:[a copyFrom:2] ifFalse:[a].
       
   643 		    rawB := (b startsWith:'*') ifTrue:[b copyFrom:2] ifFalse:[b].
       
   644 		    rawA > rawB.  ]
       
   645 !
       
   646 
       
   647 markMatchingClasses: aSelector  classesWithSelector:anOrderedCollection
   685 markMatchingClasses: aSelector  classesWithSelector:anOrderedCollection
   648 	"If an example is used, mark classes matching the example instance with an asterisk."
   686    " Matches the class of the receiver with all the elements in anOrderedCollection
   649 
   687     (which are classes with selectors). If a match is found it is marked with an asterisk. 
   650 	| unmarkedClassList firstPartOfSelector |
   688     The classes are then sorted so the the asterisk appears first. Return the 
   651 
   689     markedClassList."
   652 	"Only 'example' queries can be marked."
   690 
   653 	unmarkedClassList _ anOrderedCollection copy.
   691         | unmarkedClassList firstPartOfSelector markedClassList|
   654 
   692 
   655 
   693         unmarkedClassList:=anOrderedCollection copy.
   656 
   694 
   657 
   695         unmarkedClassList do:
   658 	unmarkedClassList do:
   696                 [:classAndMethod | | class |
   659 		[:classAndMethod | | class |
   697                 class:=Compiler evaluate:
   660 		class _ Compiler evaluate:
   698                                 ((ReadStream on: classAndMethod) upToAll: aSelector).
   661 				((ReadStream on: classAndMethod) upToAll: aSelector).
   699                 (receiver value class == class) ifTrue:
   662 		(receiver value class == class) ifTrue:
   700                         [unmarkedClassList add: '*', classAndMethod.
   663 			[unmarkedClassList add: '*', classAndMethod.
   701                         unmarkedClassList remove: classAndMethod]].
   664 			unmarkedClassList remove: classAndMethod]].
       
   665 
   702 
   666       unmarkedClassList sort:[:a :b | |rawA rawB|
   703       unmarkedClassList sort:[:a :b | |rawA rawB|
   667 		    rawA := (a startsWith:'*') ifTrue:[a copyFrom:2] ifFalse:[a].
   704                     rawA := (a startsWith:'*') ifTrue:[a copyFrom:2] ifFalse:[a].
   668 		    rawB := (b startsWith:'*') ifTrue:[b copyFrom:2] ifFalse:[b].
   705                     rawB := (b startsWith:'*') ifTrue:[b copyFrom:2] ifFalse:[b].
   669 		    rawA > rawB.  ].
   706                     rawA > rawB.  ].
   670 	 ^unmarkedClassList
   707       markedClassList:= unmarkedClassList. 
       
   708 
       
   709          ^markedClassList
   671 !
   710 !
   672 
   711 
   673 mergReciever: aReceiver WithArgument: arguments
   712 mergReciever: aReceiver WithArgument: arguments
       
   713 
       
   714 "Puts the receiver and arguments into an array so it can be of a suitable input for the
       
   715  MethodFinder. Return an array."
   674 
   716 
   675 | tempReceiver tempArguments receiverWithArgument|
   717 | tempReceiver tempArguments receiverWithArgument|
   676 
   718 
   677   tempReceiver:= aReceiver.
   719   tempReceiver:= aReceiver.
   678  tempArguments :=  arguments.
   720  tempArguments :=  arguments.
   700                                   (receiverWithArgument at:2 put: (tempArguments at:1)).
   742                                   (receiverWithArgument at:2 put: (tempArguments at:1)).
   701                                   (receiverWithArgument at:3 put: (tempArguments at:2)).
   743                                   (receiverWithArgument at:3 put: (tempArguments at:2)).
   702                                   (receiverWithArgument at:4 put: (tempArguments at:3)).
   744                                   (receiverWithArgument at:4 put: (tempArguments at:3)).
   703 
   745 
   704                                 ].  "a receiver with an argument"
   746                                 ].  "a receiver with an argument"
   705         (tempArguments size = 4)
       
   706                         ifTrue:[ receiverWithArgument:=Array new:5.
       
   707                                   receiverWithArgument at:1 put: tempReceiver.      
       
   708                                   (receiverWithArgument at:2 put: (tempArguments at:1)).
       
   709                                   (receiverWithArgument at:3 put: (tempArguments at:2)).
       
   710                                   (receiverWithArgument at:4 put: (tempArguments at:3)).
       
   711                                   (receiverWithArgument at:5 put: (tempArguments at:4)).
       
   712 
       
   713                                 ].  "a receiver with an argument"
       
   714 
   747 
   715                         ].
   748                         ].
   716 ^receiverWithArgument
   749 ^receiverWithArgument
   717 ! !
   750 ! !
   718 
   751