MethodFinderWindow.st
changeset 3292 f29412454cd5
parent 3290 19e31edb0dd6
child 3301 1663b107709f
equal deleted inserted replaced
3291:30f8b248f77c 3292:f29412454cd5
       
     1 "
       
     2  Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls)
       
     3  Copyright (C) 2001 eXept Software AG
       
     4 
       
     5  Permission is hereby granted, free of charge, to any 
       
     6  person obtaining a copy of this software and associated 
       
     7  documentation files (the 'Software'), to deal in the 
       
     8  Software without restriction, including without limitation 
       
     9  the rights to use, copy, modify, merge, publish, distribute, 
       
    10  sublicense, and/or sell copies of the Software, and to 
       
    11  permit persons to whom the Software is furnished to do so, 
       
    12  subject to the following conditions:
       
    13 
       
    14  The above copyright notice and this permission notice shall 
       
    15  be included in all copies or substantial portions of the Software.
       
    16 
       
    17  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 
       
    18  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
       
    19  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
       
    20  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
       
    21  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
       
    22  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
       
    23  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
       
    24 "
     1 "{ Package: 'stx:libtool2' }"
    25 "{ Package: 'stx:libtool2' }"
     2 
    26 
     3 "{ NameSpace: Smalltalk }"
    27 "{ NameSpace: Smalltalk }"
     4 
    28 
     5 ApplicationModel subclass:#MethodFinderWindow
    29 ApplicationModel subclass:#MethodFinderWindow
     6 	instanceVariableNames:'argumentsEditor messageAnswerEditor receiverEditor receiver
    30 	instanceVariableNames:'resultHolder selectorPatternHolder classOfResultHolder
       
    31 		selectedClassOfResultHolder selectedImplementorsHolder
       
    32 		argumentsEditor messageAnswerEditor receiverEditor receiver
     7 		resultSelectors arg2BoxVisible arg1BoxVisible arg4BoxVisible
    33 		resultSelectors arg2BoxVisible arg1BoxVisible arg4BoxVisible
     8 		arg3BoxVisible argCountHolder argCountList argument1Editor
    34 		arg3BoxVisible argCountHolder argCountList argument1Editor
     9 		argument2Editor argument3Editor argument4Editor resultSelected
    35 		argument2Editor argument3Editor argument4Editor resultSelected
    10 		lookAtResultEditor codeHolder searchProcess'
    36 		lookAtResultEditor codeHolder searchProcess'
    11 	classVariableNames:''
    37 	classVariableNames:''
    13 	category:'Interface-Tools'
    39 	category:'Interface-Tools'
    14 !
    40 !
    15 
    41 
    16 !MethodFinderWindow class methodsFor:'documentation'!
    42 !MethodFinderWindow class methodsFor:'documentation'!
    17 
    43 
       
    44 copyright
       
    45 "
       
    46  Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls)
       
    47  Copyright (C) 2001 eXept Software AG
       
    48 
       
    49  Permission is hereby granted, free of charge, to any 
       
    50  person obtaining a copy of this software and associated 
       
    51  documentation files (the 'Software'), to deal in the 
       
    52  Software without restriction, including without limitation 
       
    53  the rights to use, copy, modify, merge, publish, distribute, 
       
    54  sublicense, and/or sell copies of the Software, and to 
       
    55  permit persons to whom the Software is furnished to do so, 
       
    56  subject to the following conditions:
       
    57 
       
    58  The above copyright notice and this permission notice shall 
       
    59  be included in all copies or substantial portions of the Software.
       
    60 
       
    61  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 
       
    62  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
       
    63  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
       
    64  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
       
    65  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
       
    66  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
       
    67  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
       
    68 "
       
    69 !
       
    70 
    18 documentation
    71 documentation
    19 "
    72 "
       
    73   a tool to find implementing methods by example.
       
    74   Give it values for a receiver, optional arguments and a desired result,
       
    75   and it will find methods which do that for you.
       
    76   Please read the online documentation for details (open via the tool's help menu).
       
    77 
    20   [author:]
    78   [author:]
    21     ported from Squeak and GUI enhanced by James Hayes james@exept.de
    79     original squeak version by Ted Kaehler, Scott Wallace and Dan Ingalls.
       
    80     ported from Squeak and GUI enhanced 2001 by James Hayes james@exept.de.
       
    81     improved by Claus Gittinger.
    22 "
    82 "
    23 ! !
    83 ! !
    24 
    84 
    25 !MethodFinderWindow class methodsFor:'constants'!
    85 !MethodFinderWindow class methodsFor:'constants'!
    26 
    86 
    36     ^ '=> '.
    96     ^ '=> '.
    37     ^ '*'
    97     ^ '*'
    38 
    98 
    39     "Created: / 13.11.2001 / 12:09:52 / cg"
    99     "Created: / 13.11.2001 / 12:09:52 / cg"
    40     "Modified: / 13.11.2001 / 12:11:57 / cg"
   100     "Modified: / 13.11.2001 / 12:11:57 / cg"
       
   101 ! !
       
   102 
       
   103 !MethodFinderWindow class methodsFor:'help specs'!
       
   104 
       
   105 flyByHelpSpec
       
   106     "This resource specification was automatically generated
       
   107      by the UIHelpTool of ST/X."
       
   108 
       
   109     "Do not manually edit this!! If it is corrupted,
       
   110      the UIHelpTool may not be able to read the specification."
       
   111 
       
   112     "
       
   113      UIHelpTool openOnClass:MethodFinderWindow    
       
   114     "
       
   115 
       
   116     <resource: #help>
       
   117 
       
   118     ^ super flyByHelpSpec addPairsFrom:#(
       
   119 
       
   120 #receiverValue
       
   121 'Enter a receiver value here.\Can be a constant (like ''hello'')\or an expression, such as "Rectangle basicNew".'
       
   122 
       
   123 #answerValue
       
   124 'Enter result value here.\Can be a constant (like ''hello'')\or an expression, such as "Rectangle basicNew".'
       
   125 
       
   126 #arg1Value
       
   127 'Enter a value for the first argument here.\Can be a constant or an expression.'
       
   128 
       
   129 #arg2Value
       
   130 'Enter a value for the second argument here.\Can be a constant or an expression.'
       
   131 
       
   132 #arg3Value
       
   133 'Enter a value for the third argument here.\Can be a constant or an expression.'
       
   134 
       
   135 #argumentCount
       
   136 'Specify the number of arguments here.'
       
   137 
       
   138 #clearButton
       
   139 'Clear all sample value fields.'
       
   140 
       
   141 #startSearchButton
       
   142 'Search for methods which answer the desired value,\given the concrete arguments'
       
   143 
       
   144 #selectorPatternSearch
       
   145 'Search by name.\You can use match characters '*' as in GLOB patterns (i.e. like filename patterns)'
       
   146 
       
   147 )
    41 ! !
   148 ! !
    42 
   149 
    43 !MethodFinderWindow class methodsFor:'interface specs'!
   150 !MethodFinderWindow class methodsFor:'interface specs'!
    44 
   151 
    45 windowSpec
   152 windowSpec
    96                                layout: (LayoutFrame 0 0 0 0 0 0.34000000000000002 28 0)
   203                                layout: (LayoutFrame 0 0 0 0 0 0.34000000000000002 28 0)
    97                                translateLabel: true
   204                                translateLabel: true
    98                              )
   205                              )
    99                             (ComboListSpec
   206                             (ComboListSpec
   100                                name: 'allowedArgments'
   207                                name: 'allowedArgments'
   101                                layout: (LayoutFrame 0 0.34000000000000002 1 0 0 0.64000000000000024 28 0)
   208                                layout: (LayoutFrame 0 0.34000000000000002 1 0 0 0.64000000000000046 28 0)
       
   209                                activeHelpKey: argumentCount
   102                                model: argCountHolder
   210                                model: argCountHolder
   103                                comboList: argCountList
   211                                comboList: argCountList
   104                                useIndex: true
   212                                useIndex: true
   105                              )
   213                              )
   106                             (LabelSpec
   214                             (LabelSpec
   107                                label: 'Answer'
   215                                label: 'Answer'
   108                                name: 'MessageAnswerLabel'
   216                                name: 'MessageAnswerLabel'
   109                                layout: (LayoutFrame 0 0.64000000000000024 0 0 0 1 28 0)
   217                                layout: (LayoutFrame 0 0.64000000000000046 0 0 0 1 28 0)
       
   218                                activeHelpKey: arg1Value
   110                                translateLabel: true
   219                                translateLabel: true
   111                              )
   220                              )
   112                             (HorizontalPanelViewSpec
   221                             (HorizontalPanelViewSpec
   113                                name: 'HorizontalPanel1'
   222                                name: 'HorizontalPanel1'
   114                                layout: (LayoutFrame 0 0 30 0 0 1 0 1)
   223                                layout: (LayoutFrame 0 0 30 0 0 1 0 1)
   119                                component: 
   228                                component: 
   120                               (SpecCollection
   229                               (SpecCollection
   121                                  collection: (
   230                                  collection: (
   122                                   (WorkspaceSpec
   231                                   (WorkspaceSpec
   123                                      name: 'ReceiverEditor'
   232                                      name: 'ReceiverEditor'
       
   233                                      activeHelpKey: receiverValue
   124                                      tabable: true
   234                                      tabable: true
   125                                      hasHorizontalScrollBar: true
   235                                      hasHorizontalScrollBar: true
   126                                      hasVerticalScrollBar: true
   236                                      hasVerticalScrollBar: true
   127                                      miniScrollerHorizontal: true
   237                                      miniScrollerHorizontal: true
   128                                      miniScrollerVertical: true
   238                                      miniScrollerVertical: true
   147                                           (SpecCollection
   257                                           (SpecCollection
   148                                              collection: (
   258                                              collection: (
   149                                               (WorkspaceSpec
   259                                               (WorkspaceSpec
   150                                                  name: 'Arg1Editor'
   260                                                  name: 'Arg1Editor'
   151                                                  layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   261                                                  layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   262                                                  activeHelpKey: arg1Value
   152                                                  tabable: true
   263                                                  tabable: true
   153                                                  hasHorizontalScrollBar: true
   264                                                  hasHorizontalScrollBar: true
   154                                                  hasVerticalScrollBar: true
   265                                                  hasVerticalScrollBar: true
   155                                                  miniScrollerHorizontal: true
   266                                                  miniScrollerHorizontal: true
   156                                                  miniScrollerVertical: true
   267                                                  miniScrollerVertical: true
   170                                           (SpecCollection
   281                                           (SpecCollection
   171                                              collection: (
   282                                              collection: (
   172                                               (WorkspaceSpec
   283                                               (WorkspaceSpec
   173                                                  name: 'TextEditor5'
   284                                                  name: 'TextEditor5'
   174                                                  layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   285                                                  layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   286                                                  activeHelpKey: arg2Value
   175                                                  tabable: true
   287                                                  tabable: true
   176                                                  hasHorizontalScrollBar: true
   288                                                  hasHorizontalScrollBar: true
   177                                                  hasVerticalScrollBar: true
   289                                                  hasVerticalScrollBar: true
   178                                                  miniScrollerHorizontal: true
   290                                                  miniScrollerHorizontal: true
   179                                                  miniScrollerVertical: true
   291                                                  miniScrollerVertical: true
   193                                           (SpecCollection
   305                                           (SpecCollection
   194                                              collection: (
   306                                              collection: (
   195                                               (WorkspaceSpec
   307                                               (WorkspaceSpec
   196                                                  name: 'TextEditor6'
   308                                                  name: 'TextEditor6'
   197                                                  layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   309                                                  layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
       
   310                                                  activeHelpKey: arg3Value
   198                                                  tabable: true
   311                                                  tabable: true
   199                                                  hasHorizontalScrollBar: true
   312                                                  hasHorizontalScrollBar: true
   200                                                  hasVerticalScrollBar: true
   313                                                  hasVerticalScrollBar: true
   201                                                  miniScrollerHorizontal: true
   314                                                  miniScrollerHorizontal: true
   202                                                  miniScrollerVertical: true
   315                                                  miniScrollerVertical: true
   214                                      )
   327                                      )
   215                                      extent: (Point 110 214)
   328                                      extent: (Point 110 214)
   216                                    )
   329                                    )
   217                                   (WorkspaceSpec
   330                                   (WorkspaceSpec
   218                                      name: 'AnswerEditor'
   331                                      name: 'AnswerEditor'
       
   332                                      activeHelpKey: answerValue
   219                                      tabable: true
   333                                      tabable: true
   220                                      hasHorizontalScrollBar: true
   334                                      hasHorizontalScrollBar: true
   221                                      hasVerticalScrollBar: true
   335                                      hasVerticalScrollBar: true
   222                                      miniScrollerHorizontal: true
   336                                      miniScrollerHorizontal: true
   223                                      miniScrollerVertical: true
   337                                      miniScrollerVertical: true
   239                          layout: (LayoutFrame 0 0 -98 0.5 0 1 -75 0.5)
   353                          layout: (LayoutFrame 0 0 -98 0.5 0 1 -75 0.5)
   240                          component: 
   354                          component: 
   241                         (SpecCollection
   355                         (SpecCollection
   242                            collection: (
   356                            collection: (
   243                             (ActionButtonSpec
   357                             (ActionButtonSpec
       
   358                                activeHelpKey: clearButton    
   244                                label: 'Clear'
   359                                label: 'Clear'
   245                                name: 'Button2'
   360                                name: 'Button2'
   246                                layout: (LayoutFrame 5 0 0 0 -5 0.5 0 1)
   361                                layout: (LayoutFrame 5 0 0 0 -5 0.5 0 1)
   247                                translateLabel: true
   362                                translateLabel: true
   248                                model: clear
   363                                model: clear
   249                              )
   364                              )
   250                             (ActionButtonSpec
   365                             (ActionButtonSpec
       
   366                                activeHelpKey: startSearchButton    
   251                                label: 'Search'
   367                                label: 'Search'
   252                                name: 'Button1'
   368                                name: 'Button1'
   253                                layout: (LayoutFrame 5 0.5 0 0 -5 1 0 1)
   369                                layout: (LayoutFrame 5 0.5 0 0 -5 1 0 1)
   254                                translateLabel: true
   370                                translateLabel: true
   255                                tabable: true
   371                                tabable: true
   273                                adjust: left
   389                                adjust: left
   274                              )
   390                              )
   275                             (InputFieldSpec
   391                             (InputFieldSpec
   276                                name: 'EntryField1'
   392                                name: 'EntryField1'
   277                                layout: (LayoutFrame 2 0 -54 1 -2 1 -29 1)
   393                                layout: (LayoutFrame 2 0 -54 1 -2 1 -29 1)
   278                                model: selectorPattern
   394                                model: selectorPatternHolder
   279                                immediateAccept: true
   395                                immediateAccept: true
   280                                acceptOnReturn: true
   396                                acceptOnReturn: true
   281                                acceptOnTab: true
   397                                acceptOnTab: true
   282                                acceptOnPointerLeave: true
   398                                acceptOnPointerLeave: true
   283                              )
   399                              )
   331                          hasHorizontalScrollBar: true
   447                          hasHorizontalScrollBar: true
   332                          hasVerticalScrollBar: true
   448                          hasVerticalScrollBar: true
   333                          autoHideScrollBars: true
   449                          autoHideScrollBars: true
   334                          hasKeyboardFocusInitially: false
   450                          hasKeyboardFocusInitially: false
   335                          postBuildCallback: sourceCodeWidgetCreated:
   451                          postBuildCallback: sourceCodeWidgetCreated:
       
   452                          viewClassName: 'codeViewClass'
   336                        )
   453                        )
   337                       )
   454                       )
   338                     
   455                     
   339                    )
   456                    )
   340                    handles: (Any 0.5 1.0)
   457                    handles: (Any 0.5 1.0)
   341                  )
   458                  )
   342                 )
   459                 )
   343               
   460               
   344              )
   461              )
   345              handles: (Any 0.37391304347826093 1.0)
   462              handles: (Any 0.37391304347826104 1.0)
   346            )
   463            )
   347           )
   464           )
   348         
   465         
   349        )
   466        )
   350      )
   467      )
   482 openOnSelectorPattern:selector
   599 openOnSelectorPattern:selector
   483     |app|
   600     |app|
   484 
   601 
   485     app := self new.
   602     app := self new.
   486     app allButOpen.
   603     app allButOpen.
   487     app selectorPattern value:selector.
   604     app selectorPatternHolder value:selector.
   488     app openWindow.
   605     app openWindow.
   489     "/ app waitForBackgroundSearchFinished.
   606     "/ app waitForBackgroundSearchFinished.
   490     
   607     
   491     ^ app
   608     ^ app
   492 
   609 
   503     ^ receiver copy
   620     ^ receiver copy
   504 ! !
   621 ! !
   505 
   622 
   506 !MethodFinderWindow methodsFor:'actions'!
   623 !MethodFinderWindow methodsFor:'actions'!
   507 
   624 
   508 argumentEditorsContents
       
   509 
       
   510 "Determine how many text editors of the arguments are used and store the result
       
   511 as argCounter. The result being the minimum between how many editors have
       
   512 expressions in and how many are displayed.
       
   513 
       
   514 Add each argument string (key)and the evaluated version (value) to an Ordered Dictionary
       
   515 from each of the text editors.
       
   516 
       
   517 Return the OrderedDictionary with the expressions from all the text editors. "
       
   518 
       
   519      | tempArguments argCounter tempArgument1Editor tempArgument2Editor tempArgument3Editor
       
   520 associationKey associationValue|
       
   521 
       
   522 argCounter:=0.
       
   523 
       
   524 tempArgument1Editor:= (self cleanInputs: argument1Editor contents).
       
   525 tempArgument2Editor:=  (self cleanInputs: argument2Editor contents).
       
   526 tempArgument3Editor:= (self cleanInputs: argument3Editor contents).
       
   527 
       
   528 tempArgument1Editor = '' ifFalse:[argCounter:=argCounter +1].
       
   529 tempArgument2Editor = '' ifFalse:[argCounter:=argCounter +1].
       
   530 tempArgument3Editor = '' ifFalse:[argCounter:=argCounter +1].
       
   531 
       
   532 
       
   533 argCounter:= (argCounter min: (self argCountHolder value -1)).
       
   534 tempArguments:= OrderedDictionary new:argCounter. 
       
   535 
       
   536 (argCounter value >= 1) 
       
   537                 ifTrue:[associationValue:= (Compiler evaluate: tempArgument1Editor).
       
   538                         ((self isExpression:tempArgument1Editor) or:[ associationValue isNil]) ifTrue:[                  "looks if an expression is typed in"
       
   539                                         associationKey:=associationValue printString]
       
   540                                                           ifFalse:[
       
   541                                         associationKey:=tempArgument1Editor].
       
   542 
       
   543                         tempArguments add: associationKey-> associationValue.
       
   544                         ].
       
   545 (argCounter value >= 2) 
       
   546                 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument2Editor).
       
   547                         (((self isExpression:tempArgument2Editor) or:[ associationValue isNil])) ifTrue:[                  "looks if an expression is typed in"
       
   548                                         associationKey:=associationValue printString]
       
   549                                                           ifFalse:[
       
   550                                         associationKey:=tempArgument2Editor].
       
   551 
       
   552                         tempArguments add: associationKey-> associationValue].
       
   553 
       
   554 (argCounter value >= 3)
       
   555                 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument3Editor).
       
   556                         ((self isExpression:tempArgument3Editor) or:[ associationValue isNil]) ifTrue:[                  "looks if an expression is typed in"
       
   557                                         associationKey:=associationValue printString]
       
   558                                                           ifFalse:[
       
   559                                         associationKey:=tempArgument3Editor].
       
   560 
       
   561                         tempArguments add: associationKey-> associationValue].
       
   562 
       
   563 
       
   564 ^tempArguments
       
   565 !
       
   566 
       
   567 clear
   625 clear
   568     "Reset the contents of all the outputs. Return the receiver."
   626     "Reset the contents of all the outputs."
   569 
   627 
   570     receiverEditor contents:nil.
   628     receiverEditor contents:nil.
   571     argument1Editor contents:nil.
   629     argument1Editor contents:nil.
   572     argument2Editor contents:nil.
   630     argument2Editor contents:nil.
   573     argument3Editor contents:nil.
   631     argument3Editor contents:nil.
   575     self resultHolder value:nil.
   633     self resultHolder value:nil.
   576     self classOfResultHolder value: nil.
   634     self classOfResultHolder value: nil.
   577     codeHolder value:nil.
   635     codeHolder value:nil.
   578 !
   636 !
   579 
   637 
   580 extractClassAndSelectorFrom:anArgument 
       
   581     "Opens browser on theArgument of a specific class. anArgument being a string with the
       
   582        Class and the selector upon which the browser is to be opened. Return the receiver."
       
   583 
       
   584     |aClass aSelector x theArgument marker|
       
   585 
       
   586     anArgument isNil ifTrue:[
       
   587         ^ nil
       
   588     ].
       
   589     marker := self class markerForImplementingClass.
       
   590 
       
   591     theArgument := anArgument string withoutPrefix:marker.
       
   592     aClass := theArgument copyUpTo:(Character space).
       
   593     x := aClass size + 2.
       
   594     aSelector := theArgument copyFrom:x.
       
   595     aClass := Smalltalk classNamed:aClass.
       
   596     (aSelector startsWith:'class ') ifTrue:[
       
   597         aSelector := aSelector withoutPrefix:'class '.
       
   598         aClass := aClass class.
       
   599     ].
       
   600     ^ aClass -> aSelector asSymbol
       
   601 
       
   602 "
       
   603 MethodFinderWindow new extractClassAndSelectorFrom: '*SmallInteger +'
       
   604 MethodFinderWindow new extractClassAndSelectorFrom: 'String ,'       
       
   605 MethodFinderWindow new extractClassAndSelectorFrom: 'Number detentBy:atMultiplesOf:snap:' 
       
   606 
       
   607 
       
   608 "
       
   609 
       
   610     "Modified: / 27-04-2012 / 15:05:53 / cg"
       
   611 !
       
   612 
       
   613 isExpression:aString 
       
   614     "Return true or false depending on if the subString includes certain characters"
       
   615     
       
   616     (aString includesSubString:': ') ifTrue:[
       
   617         ^ true
       
   618     ].
       
   619     (aString includes:$+) ifTrue:[
       
   620         ^ true
       
   621     ].
       
   622     (aString includes:$-) ifTrue:[
       
   623         ^ true
       
   624     ].
       
   625     (aString includes:$*) ifTrue:[
       
   626         ^ true
       
   627     ].
       
   628     (aString includes:$/) ifTrue:[
       
   629         ^ true
       
   630     ].
       
   631     (aString includes:$>) ifTrue:[
       
   632         ^ true
       
   633     ].
       
   634     (aString includes:$<) ifTrue:[
       
   635         ^ true
       
   636     ].
       
   637     (aString includesSubString:' new') ifTrue:[
       
   638         ^ true
       
   639     ].
       
   640     (aString includes:$[) 
       
   641         & (aString includes:$]) 
       
   642         & (aString includes:$.) ifTrue:[ ^ false ].
       
   643 
       
   644     (aString includes:$.) ifTrue:[
       
   645         ^ true
       
   646     ].
       
   647     ^ false
       
   648 !
       
   649 
       
   650 messageAnswerEditorContents
   638 messageAnswerEditorContents
   651     "Return a cleaned up version of message answer taken from the messageAnswerEditor
   639     "Return a cleaned up version of message answer taken from the messageAnswerEditor
   652      as an association. The association has cleanedAnswerString as a key and the
   640      as an association. The association has cleanedAnswerString as a key and the
   653      compiledAnswer as value."
   641      compiledAnswer as value."
   654     
   642     
   723     selIndex := self selectedImplementorsHolder value.
   711     selIndex := self selectedImplementorsHolder value.
   724     selIndex isNil ifTrue:[^ self].
   712     selIndex isNil ifTrue:[^ self].
   725 
   713 
   726     selector := resultSelectors at:selIndex.
   714     selector := resultSelectors at:selIndex.
   727     UserPreferences browserClass browseSendersOf:selector.
   715     UserPreferences browserClass browseSendersOf:selector.
   728 !
       
   729 
       
   730 receiverEditorContents
       
   731     "Return a cleaned up version of receiver taken from the receiverEditor
       
   732      as an association. The association has aCleanedRecieverString as a key and the
       
   733      compiledReceiver as value."
       
   734     
       
   735     |aCleanedRecieverString compiledReceiver|
       
   736 
       
   737     aCleanedRecieverString := self cleanInputs:(receiverEditor contents).
       
   738     compiledReceiver := Compiler evaluate:aCleanedRecieverString.
       
   739     ((self isExpression:aCleanedRecieverString) or:[ compiledReceiver isNil ]) ifTrue:[
       
   740         aCleanedRecieverString := compiledReceiver printString
       
   741     ].
       
   742     ^ aCleanedRecieverString -> compiledReceiver.
       
   743 !
   716 !
   744 
   717 
   745 search
   718 search
   746     "Do a search based on the input in the various text editors. Return the receiver."
   719     "Do a search based on the input in the various text editors. Return the receiver."
   747     
   720     
   753     tempArguments := self argumentEditorsContents.
   726     tempArguments := self argumentEditorsContents.
   754     tempReceiver := self receiverEditorContents.
   727     tempReceiver := self receiverEditorContents.
   755     tempAnswer := self messageAnswerEditorContents.
   728     tempAnswer := self messageAnswerEditorContents.
   756      "self cleanInputRec:tempReceiver arg:tempArguments ans:tempAnswer."
   729      "self cleanInputRec:tempReceiver arg:tempArguments ans:tempAnswer."
   757     anArray := Array new:2.
   730     anArray := Array new:2.
   758     receiverWithArgument := self mergReciever:(tempReceiver value)
   731     receiverWithArgument := self mergeReceiver:(tempReceiver value)
   759             WithArgument:(tempArguments values).
   732                                  withArgument:(tempArguments values).
   760     anArray
   733     anArray
   761         at:1 put:receiverWithArgument;
   734         at:1 put:receiverWithArgument;
   762         at:2 put:tempAnswer value.
   735         at:2 put:tempAnswer value.
   763      "an array now holds the following array #(#(receiver argument) answer) or #(#(reciever) answer). which should
   736      "an array now holds the following array #(#(receiver argument) answer) or #(#(reciever) answer). which should
   764      be suitable input for the method finder."
   737      be suitable input for the method finder."
   804     receiver := tempReceiver
   777     receiver := tempReceiver
   805 
   778 
   806     "Modified: / 26-09-2011 / 12:42:28 / cg"
   779     "Modified: / 26-09-2011 / 12:42:28 / cg"
   807 !
   780 !
   808 
   781 
   809 searchPatternChanged
       
   810     self searchPatternMatchesInBackground
       
   811 
       
   812     "Created: / 01-06-2012 / 13:18:16 / cg"
       
   813 !
       
   814 
       
   815 searchPatternMatchesInBackground
   782 searchPatternMatchesInBackground
   816     "Do a search based on the pattern match as a background task"
   783     "Do a search based on the pattern match as a background task"
   817 
   784 
   818     | p pattern|
   785     | p pattern|
   819 
   786 
   820     (p := searchProcess) notNil ifTrue:[
   787     (p := searchProcess) notNil ifTrue:[
   821         searchProcess := nil.
   788         searchProcess := nil.
   822         p terminate.
   789         p terminate.
   823     ].
   790     ].
   824 
   791 
   825     pattern := self selectorPattern value.
   792     pattern := self selectorPatternHolder value.
   826     pattern isEmptyOrNil ifTrue:[
   793     pattern isEmptyOrNil ifTrue:[
   827         self resultHolder value:self resultInfoText.
   794         self resultHolder value:self resultInfoText.
   828         self classOfResultHolder value:nil.
   795         self classOfResultHolder value:nil.
   829         self codeHolder value:nil.
   796         self codeHolder value:nil.
   830         ^ self
   797         ^ self
   835             |list counts firsts seconds selectors resultList idx match|
   802             |list counts firsts seconds selectors resultList idx match|
   836 
   803 
   837             self withCursor:Cursor execute do:[
   804             self withCursor:Cursor execute do:[
   838                 pattern includesMatchCharacters ifFalse:[   
   805                 pattern includesMatchCharacters ifFalse:[   
   839                     list := SystemBrowser findImplementorsOf:pattern in:Smalltalk allClasses ignoreCase:true.
   806                     list := SystemBrowser findImplementorsOf:pattern in:Smalltalk allClasses ignoreCase:true.
       
   807                     list isEmptyOrNil ifTrue:[
       
   808                         match := pattern,'*'.
       
   809                         list := SystemBrowser findImplementorsMatching:match in:Smalltalk allClasses ignoreCase:true.
       
   810                     ].
   840                 ] ifTrue:[
   811                 ] ifTrue:[
   841                     match := '*',pattern,'*'.
   812                     "/ match := '*',pattern,'*'.
       
   813                     match := pattern.
   842                     list := SystemBrowser findImplementorsMatching:match in:Smalltalk allClasses ignoreCase:true.
   814                     list := SystemBrowser findImplementorsMatching:match in:Smalltalk allClasses ignoreCase:true.
   843                 ].
   815                 ].
   844             ].
   816             ].
   845 
   817 
   846             counts := IdentityDictionary new.
   818             counts := IdentityDictionary new.
   876                                     ] ifFalse:[
   848                                     ] ifFalse:[
   877                                         s , cnt printString , ' implementor(s)'
   849                                         s , cnt printString , ' implementor(s)'
   878                                     ]
   850                                     ]
   879                                 ].
   851                                 ].
   880                             ].
   852                             ].
       
   853                             
   881             self enqueueDelayedAction:[ self updateListAfterPatternSearch: resultList ].
   854             self enqueueDelayedAction:[ self updateListAfterPatternSearch: resultList ].
   882             "/ is it in the list?
       
   883             idx := resultSelectors indexOf:pattern.
       
   884             idx ~~ 0 ifTrue:[
       
   885                 self enqueueDelayedAction:[ self selectedImplementorsHolder value:idx ].
       
   886             ].    
       
   887             
       
   888         ] fork.
   855         ] fork.
   889 
   856 
   890     "Created: / 01-06-2012 / 13:16:54 / cg"
   857     "Created: / 01-06-2012 / 13:16:54 / cg"
   891 !
       
   892 
       
   893 selectedClassOfResultHolderChanged
       
   894     |sel classAndSelector mthd|
       
   895 
       
   896     sel := self selectedClassOfResultHolder value.
       
   897 
       
   898     classAndSelector := self extractClassAndSelectorFrom:sel.
       
   899     classAndSelector isNil ifTrue:[
       
   900         ^ self
       
   901     ].
       
   902     mthd := classAndSelector key >> classAndSelector value.   
       
   903     mthd notNil ifTrue:[
       
   904         self withWaitCursorDo:[
       
   905             self codeHolder value:mthd source
       
   906         ]
       
   907     ] ifFalse:[
       
   908         self codeHolder value:nil
       
   909     ].
       
   910 
       
   911     "Created: / 13.11.2001 / 12:43:43 / cg"
       
   912     "Modified: / 13.11.2001 / 12:48:56 / cg"
       
   913 !
   858 !
   914 
   859 
   915 updateImplementorsOf:anInteger 
   860 updateImplementorsOf:anInteger 
   916     "Request the implementors of the selected argument provided by aNumber.
   861     "Request the implementors of the selected argument provided by aNumber.
   917      Return the receiver."
   862      Return the receiver."
   943     ].
   888     ].
   944 
   889 
   945     "Modified (comment): / 24-06-2012 / 18:41:45 / cg"
   890     "Modified (comment): / 24-06-2012 / 18:41:45 / cg"
   946 !
   891 !
   947 
   892 
   948 updateListAfterPatternSearch:resultList 
   893 updateListAfterPatternSearch:resultList
       
   894     |searchPattern idx|
       
   895     
   949     self classOfResultHolder value:nil.
   896     self classOfResultHolder value:nil.
   950     self codeHolder value:nil.
   897     self codeHolder value:nil.
   951     self resultHolder value:resultList.
   898     self resultHolder value:resultList.
   952 
   899 
   953     "Created: / 01-06-2012 / 13:17:34 / cg"
   900     searchPattern := self selectorPatternHolder value.
   954 !
   901     "/ is the search pattern in the list (i.e. a perfect match)?
   955 
   902     "/ Then select it.
   956 waitForBackgroundSearchFinished
   903     idx := resultSelectors indexOf:searchPattern.
   957     | p |
   904     idx ~~ 0 ifTrue:[
   958 
   905         self selectedImplementorsHolder setValue:idx; changed
   959     (p := searchProcess) isNil ifTrue:[^ self].
   906     ].    
   960     p isDead ifTrue:[^ self].
       
   961     p waitUntilTerminated 
       
   962 ! !
   907 ! !
   963 
   908 
   964 !MethodFinderWindow methodsFor:'aspects'!
   909 !MethodFinderWindow methodsFor:'aspects'!
   965 
   910 
   966 arg1BoxVisible
   911 arg1BoxVisible
   967 "Determines if the box should be visble or not. Return true or false"
   912     "Determines if the box should be visible or not. 
       
   913      Return a holder providing true or false"
       
   914 
   968     arg1BoxVisible isNil ifTrue:[
   915     arg1BoxVisible isNil ifTrue:[
   969         arg1BoxVisible := BlockValue
   916         arg1BoxVisible := BlockValue
   970                               with:[:vh | vh value >= 2 ]
   917                               with:[:vh | vh value >= 2 ]
   971                               argument:(self argCountHolder)
   918                               argument:(self argCountHolder)
   972     ].
   919     ].
   973     ^ arg1BoxVisible.
   920     ^ arg1BoxVisible.
   974 !
   921 !
   975 
   922 
   976 arg2BoxVisible
   923 arg2BoxVisible
   977 "Determines if the box should be visble or not. Return true or false"
   924     "Determines if the box should be visible or not. 
       
   925      Return a holder providing true or false"
       
   926 
   978     arg2BoxVisible isNil ifTrue:[
   927     arg2BoxVisible isNil ifTrue:[
   979         arg2BoxVisible := BlockValue
   928         arg2BoxVisible := BlockValue
   980                               with:[:vh | vh value >= 3 ]
   929                               with:[:vh | vh value >= 3 ]
   981                               argument:(self argCountHolder)
   930                               argument:(self argCountHolder)
   982     ].
   931     ].
   983     ^ arg2BoxVisible.
   932     ^ arg2BoxVisible.
   984 !
   933 !
   985 
   934 
   986 arg3BoxVisible
   935 arg3BoxVisible
   987 "Determines if the box should be visble or not. Return true or false"
   936     "Determines if the box should be visible or not. 
       
   937      Return a holder providing true or false"
       
   938 
   988     arg3BoxVisible isNil ifTrue:[
   939     arg3BoxVisible isNil ifTrue:[
   989         arg3BoxVisible := BlockValue
   940         arg3BoxVisible := BlockValue
   990                               with:[:vh | vh value >= 4 ]
   941                               with:[:vh | vh value >= 4 ]
   991                               argument:(self argCountHolder)
   942                               argument:(self argCountHolder)
   992     ].
   943     ].
   993     ^ arg3BoxVisible.
   944     ^ arg3BoxVisible.
   994 !
   945 !
   995 
   946 
   996 arg4BoxVisible
   947 arg4BoxVisible
   997 "Determines if the box should be visble or not. Return true or false"
   948     "Determines if the box should be visible or not. 
       
   949      Return a holder providing true or false"
       
   950 
   998     arg4BoxVisible isNil ifTrue:[
   951     arg4BoxVisible isNil ifTrue:[
   999         arg4BoxVisible := BlockValue
   952         arg4BoxVisible := BlockValue
  1000                               with:[:vh | vh value >= 5 ]
   953                               with:[:vh | vh value >= 5 ]
  1001                               argument:(self argCountHolder)
   954                               argument:(self argCountHolder)
  1002     ].
   955     ].
  1003     ^ arg4BoxVisible.
   956     ^ arg4BoxVisible.
  1004 !
   957 !
  1005 
   958 
  1006 argCountHolder
   959 argCountHolder
  1007 "Return the value of argCounterHolder which is initialized at 2."
   960     "Return an argCounterHolder which is initialized at 2."
       
   961     
  1008     argCountHolder isNil ifTrue:[
   962     argCountHolder isNil ifTrue:[
  1009         argCountHolder := 2 asValue.
   963         argCountHolder := 2 asValue.
  1010     ].     
   964     ].     
  1011     ^ argCountHolder.
   965     ^ argCountHolder.
  1012 !
   966 !
  1013 
   967 
  1014 argCountList
   968 argCountList
  1015 "Return the argCountList"
   969     "Return the argCountList (shown in the combo)"
       
   970 
  1016     argCountList isNil ifTrue:[
   971     argCountList isNil ifTrue:[
  1017         argCountList := #('0 arguments' '1 argument' '2 arguments' '3 arguments') asValue  
   972         argCountList := #('0 arguments' '1 argument' '2 arguments' '3 arguments') asValue  
  1018     ].
   973     ].
  1019     ^ argCountList.
   974     ^ argCountList.
  1020 !
   975 !
  1021 
   976 
  1022 classOfResultHolder
   977 classOfResultHolder
  1023     "Return a valueHolder which contains a collection with the names of the 
   978     "Return a valueHolder which contains a collection with the names of the 
  1024      implementors of a specific message.   "
   979      implementors of a specific message.   "
  1025 
   980 
  1026     |holder|
   981     classOfResultHolder isNil ifTrue:[
  1027     (holder := builder bindingAt:#classOfResultHolder) isNil ifTrue:[
   982         classOfResultHolder := ValueHolder new.
  1028         holder := ValueHolder new.
   983     ].
  1029         builder aspectAt:#classOfResultHolder put:holder
   984     ^ classOfResultHolder
  1030     ].
       
  1031     ^ holder
       
  1032 !
   985 !
  1033 
   986 
  1034 codeHolder
   987 codeHolder
  1035     codeHolder isNil ifTrue:[
   988     codeHolder isNil ifTrue:[
  1036         codeHolder := '' asValue.
   989         codeHolder := '' asValue.
  1038     ^ codeHolder.
   991     ^ codeHolder.
  1039 
   992 
  1040     "Created: / 13.11.2001 / 12:44:11 / cg"
   993     "Created: / 13.11.2001 / 12:44:11 / cg"
  1041 !
   994 !
  1042 
   995 
       
   996 codeViewClass
       
   997     "the species of view to be created as codeview"
       
   998     
       
   999     ^ Tools::CodeView2 ? CodeView
       
  1000 !
       
  1001 
  1043 resultHolder
  1002 resultHolder
  1044     "Return a value holder which contains the results of a search as a collection."
  1003     "Return a value holder which contains the results of a search as a collection."
  1045 
  1004 
  1046     |holder|
  1005     resultHolder isNil ifTrue:[
  1047     (holder := builder bindingAt:#resultHolder) isNil ifTrue:[
  1006         resultHolder := ValueHolder new.
  1048         holder := ValueHolder new.
  1007         resultHolder value:(self resultInfoText collect:[:l | l withColor:Color darkGrey]).
  1049         builder aspectAt:#resultHolder put:holder.
  1008     ].
  1050         holder value:(self resultInfoText collect:[:l | l withColor:Color darkGrey]).
  1009     ^ resultHolder.
  1051     ].
       
  1052     ^ holder.
       
  1053 
  1010 
  1054     "Modified: / 01-06-2012 / 13:06:02 / cg"
  1011     "Modified: / 01-06-2012 / 13:06:02 / cg"
  1055 !
  1012 !
  1056 
  1013 
  1057 resultInfoText
  1014 resultInfoText
  1066 !
  1023 !
  1067 
  1024 
  1068 selectedClassOfResultHolder
  1025 selectedClassOfResultHolder
  1069     "valueHolder which contains the index of the selected result class (right list)"
  1026     "valueHolder which contains the index of the selected result class (right list)"
  1070 
  1027 
  1071     |holder|
  1028     selectedClassOfResultHolder isNil ifTrue:[
  1072 
  1029         selectedClassOfResultHolder := ValueHolder new.
  1073     (holder := builder bindingAt:#selectedClassOfResultHolder) isNil ifTrue:[
  1030     ].
  1074         holder := ValueHolder new.
  1031     ^ selectedClassOfResultHolder
  1075         builder aspectAt:#selectedClassOfResultHolder put:holder
       
  1076     ].
       
  1077     ^ holder
       
  1078 
  1032 
  1079     "Modified (comment): / 21-09-2012 / 11:10:29 / cg"
  1033     "Modified (comment): / 21-09-2012 / 11:10:29 / cg"
  1080 !
  1034 !
  1081 
  1035 
  1082 selectedImplementorsHolder
  1036 selectedImplementorsHolder
  1083     "valueHolder which contains the index of the selected implementors list (left list)"
  1037     "valueHolder which contains the index of the selected implementors list (left list)"
  1084 
  1038 
  1085     |holder|
  1039     selectedImplementorsHolder isNil ifTrue:[
  1086 
  1040         selectedImplementorsHolder := ValueHolder new.
  1087     (holder := builder bindingAt:#selectedImplementorsHolder) isNil ifTrue:[
  1041         selectedImplementorsHolder onChangeEvaluate:[self updateImplementorsOf:selectedImplementorsHolder value].
  1088         holder := ValueHolder new.
  1042     ].
  1089         holder onChangeEvaluate:[self updateImplementorsOf:holder value].
  1043     ^ selectedImplementorsHolder
  1090         builder aspectAt:#selectedImplementorsHolder put:holder
       
  1091     ].
       
  1092     ^ holder
       
  1093 
  1044 
  1094     "Created: / 21-09-2012 / 11:10:13 / cg"
  1045     "Created: / 21-09-2012 / 11:10:13 / cg"
  1095 !
  1046 !
  1096 
  1047 
  1097 selectorPattern
  1048 selectorPatternHolder
  1098     |holder|
  1049     selectorPatternHolder isNil ifTrue:[
  1099     (holder := builder bindingAt:#selectorPattern) isNil ifTrue:[
  1050         selectorPatternHolder := ValueHolder new.
  1100         holder := ValueHolder new.
  1051         selectorPatternHolder onChangeSend:#selectorPatternChanged to:self.
  1101         builder aspectAt:#selectorPattern put:holder.
  1052     ].
  1102         holder onChangeSend:#searchPatternChanged to:self.
  1053     ^ selectorPatternHolder
  1103     ].
       
  1104     ^ holder
       
  1105 
  1054 
  1106     "Created: / 27-04-2012 / 14:44:01 / cg"
  1055     "Created: / 27-04-2012 / 14:44:01 / cg"
  1107 ! !
       
  1108 
       
  1109 !MethodFinderWindow methodsFor:'callBacks'!
       
  1110 
       
  1111 argument1WidgetCreated: aWidget
       
  1112 "Store the widget as an instance variable. Return the receiver"
       
  1113 
       
  1114 
       
  1115         argument1Editor := aWidget scrolledView.
       
  1116         aWidget tabMeansNextField:true.
       
  1117 
       
  1118     "Modified: / 13.11.2001 / 12:21:41 / cg"
       
  1119 !
       
  1120 
       
  1121 argument2WidgetCreated: aWidget
       
  1122 "Store the widget as an instance variable. Return the receiver"
       
  1123 
       
  1124 
       
  1125         argument2Editor := aWidget scrolledView.
       
  1126         aWidget tabMeansNextField:true.
       
  1127 
       
  1128     "Modified: / 13.11.2001 / 12:21:45 / cg"
       
  1129 !
       
  1130 
       
  1131 argument3WidgetCreated: aWidget
       
  1132 "Store the widget as an instance variable. Return the receiver"
       
  1133 
       
  1134 
       
  1135         argument3Editor := aWidget scrolledView.
       
  1136         aWidget tabMeansNextField:true.
       
  1137 
       
  1138     "Modified: / 13.11.2001 / 12:21:49 / cg"
       
  1139 !
       
  1140 
       
  1141 messageAnswerWidgetCreated: aWidget
       
  1142 "Store the widget as an instance variable. Return the receiver"
       
  1143 
       
  1144         messageAnswerEditor := aWidget scrolledView.
       
  1145         aWidget tabMeansNextField:true.
       
  1146 
       
  1147     "Modified: / 13.11.2001 / 12:24:55 / cg"
       
  1148 !
       
  1149 
       
  1150 openHTMLDocumentation
       
  1151     HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#METHODFINDER'
       
  1152 !
       
  1153 
       
  1154 receiverWidgetCreated: aWidget
       
  1155 "Store the widget as an instance variable. Return the receiver"
       
  1156 
       
  1157         receiverEditor := aWidget scrolledView.
       
  1158         aWidget tabMeansNextField:true.
       
  1159 
       
  1160     "Modified: / 13.11.2001 / 12:24:49 / cg"
       
  1161 !
       
  1162 
       
  1163 sourceCodeWidgetCreated: aWidget
       
  1164         aWidget acceptAction:nil.
       
  1165         aWidget readOnly:true
       
  1166 
       
  1167     "Created: / 13.11.2001 / 12:50:27 / cg"
       
  1168     "Modified: / 13.11.2001 / 12:51:23 / cg"
       
  1169 ! !
  1056 ! !
  1170 
  1057 
  1171 !MethodFinderWindow methodsFor:'controlInput'!
  1058 !MethodFinderWindow methodsFor:'controlInput'!
  1172 
  1059 
  1173 cleanInputs:aDirtyString 
  1060 cleanInputs:aDirtyString 
  1256     ^ markedClassList
  1143     ^ markedClassList
  1257 
  1144 
  1258     "Modified: / 13.11.2001 / 12:16:05 / cg"
  1145     "Modified: / 13.11.2001 / 12:16:05 / cg"
  1259 !
  1146 !
  1260 
  1147 
  1261 mergReciever: aReceiver WithArgument: arguments
  1148 mergeReceiver: aReceiver withArgument: arguments
  1262 
  1149 
  1263 "Puts the receiver and arguments into an array so it can be of a suitable input for the
  1150 "Puts the receiver and arguments into an array so it can be of a suitable input for the
  1264  MethodFinder. Return an array."
  1151  MethodFinder. Return an array."
  1265 
  1152 
  1266 | tempReceiver tempArguments receiverWithArgument|
  1153 | tempReceiver tempArguments receiverWithArgument|
  1296 
  1183 
  1297                         ].
  1184                         ].
  1298 ^receiverWithArgument
  1185 ^receiverWithArgument
  1299 ! !
  1186 ! !
  1300 
  1187 
  1301 !MethodFinderWindow methodsFor:'misc'!
  1188 !MethodFinderWindow methodsFor:'initialization'!
       
  1189 
       
  1190 argument1WidgetCreated: aWidget
       
  1191     "UI post creation hook. remember the widget as an instance variable."
       
  1192 
       
  1193     argument1Editor := aWidget scrolledView.
       
  1194     aWidget tabMeansNextField:true.
       
  1195 
       
  1196     "Modified: / 13.11.2001 / 12:21:41 / cg"
       
  1197 !
       
  1198 
       
  1199 argument2WidgetCreated: aWidget
       
  1200     "UI post creation hook. remember the widget as an instance variable."
       
  1201 
       
  1202     argument2Editor := aWidget scrolledView.
       
  1203     aWidget tabMeansNextField:true.
       
  1204 
       
  1205     "Modified: / 13.11.2001 / 12:21:45 / cg"
       
  1206 !
       
  1207 
       
  1208 argument3WidgetCreated: aWidget
       
  1209     "UI post creation hook. remember the widget as an instance variable"
       
  1210 
       
  1211     argument3Editor := aWidget scrolledView.
       
  1212     aWidget tabMeansNextField:true.
       
  1213 
       
  1214     "Modified: / 13.11.2001 / 12:21:49 / cg"
       
  1215 !
       
  1216 
       
  1217 messageAnswerWidgetCreated: aWidget
       
  1218     "UI post creation hook. remember the widget as an instance variable."
       
  1219 
       
  1220     messageAnswerEditor := aWidget scrolledView.
       
  1221     aWidget tabMeansNextField:true.
       
  1222 
       
  1223     "Modified: / 13.11.2001 / 12:24:55 / cg"
       
  1224 !
       
  1225 
       
  1226 receiverWidgetCreated: aWidget
       
  1227     "UI post creation hook. remember the widget as an instance variable."
       
  1228 
       
  1229     receiverEditor := aWidget scrolledView.
       
  1230     aWidget tabMeansNextField:true.
       
  1231 
       
  1232     "Modified: / 13.11.2001 / 12:24:49 / cg"
       
  1233 !
       
  1234 
       
  1235 sourceCodeWidgetCreated: aWidget
       
  1236     "UI post creation hook. make the codeView readonly"
       
  1237     
       
  1238     aWidget acceptAction:nil.
       
  1239     aWidget readOnly:true
       
  1240 
       
  1241     "Created: / 13.11.2001 / 12:50:27 / cg"
       
  1242     "Modified: / 13.11.2001 / 12:51:23 / cg"
       
  1243 ! !
       
  1244 
       
  1245 !MethodFinderWindow methodsFor:'menu actions'!
  1302 
  1246 
  1303 aboutThisApplicationText
  1247 aboutThisApplicationText
  1304     |msg|
  1248     |msg|
  1305 
  1249 
  1306     msg := super aboutThisApplicationText.
  1250     msg := super aboutThisApplicationText.
  1307     msg := msg , '\\Ported from Squeak to ST/X by James Hayes (james@exept.de).
  1251     msg := msg , '\\Original written by Ted Kaehler, Scott Wallace and Dan Ingalls.
  1308 Original written by Ted Kaehler, Scott Wallace and Dan Ingalls.'.
  1252 Ported from Squeak to ST/X by James Hayes (2001 james@exept.de).
       
  1253 Improved by Claus Gittinger.    
       
  1254 '.
  1309     ^msg withCRs.
  1255     ^msg withCRs.
  1310 
  1256 
  1311     "Modified: / 13.11.2001 / 12:56:44 / cg"
  1257     "Modified: / 13.11.2001 / 12:56:44 / cg"
       
  1258 !
       
  1259 
       
  1260 openHTMLDocumentation
       
  1261     "about/help menu action"
       
  1262     
       
  1263     HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#METHODFINDER'
       
  1264 ! !
       
  1265 
       
  1266 !MethodFinderWindow methodsFor:'private'!
       
  1267 
       
  1268 argumentEditorsContents
       
  1269 
       
  1270 "Determine how many text editors of the arguments are used and store the result
       
  1271 as argCounter. The result being the minimum between how many editors have
       
  1272 expressions in and how many are displayed.
       
  1273 
       
  1274 Add each argument string (key)and the evaluated version (value) to an Ordered Dictionary
       
  1275 from each of the text editors.
       
  1276 
       
  1277 Return the OrderedDictionary with the expressions from all the text editors. "
       
  1278 
       
  1279      | tempArguments argCounter tempArgument1Editor tempArgument2Editor tempArgument3Editor
       
  1280 associationKey associationValue|
       
  1281 
       
  1282 argCounter:=0.
       
  1283 
       
  1284 tempArgument1Editor:= (self cleanInputs: argument1Editor contents).
       
  1285 tempArgument2Editor:=  (self cleanInputs: argument2Editor contents).
       
  1286 tempArgument3Editor:= (self cleanInputs: argument3Editor contents).
       
  1287 
       
  1288 tempArgument1Editor = '' ifFalse:[argCounter:=argCounter +1].
       
  1289 tempArgument2Editor = '' ifFalse:[argCounter:=argCounter +1].
       
  1290 tempArgument3Editor = '' ifFalse:[argCounter:=argCounter +1].
       
  1291 
       
  1292 
       
  1293 argCounter:= (argCounter min: (self argCountHolder value -1)).
       
  1294 tempArguments:= OrderedDictionary new:argCounter. 
       
  1295 
       
  1296 (argCounter value >= 1) 
       
  1297                 ifTrue:[associationValue:= (Compiler evaluate: tempArgument1Editor).
       
  1298                         ((self isExpression:tempArgument1Editor) or:[ associationValue isNil]) ifTrue:[                  "looks if an expression is typed in"
       
  1299                                         associationKey:=associationValue printString]
       
  1300                                                           ifFalse:[
       
  1301                                         associationKey:=tempArgument1Editor].
       
  1302 
       
  1303                         tempArguments add: associationKey-> associationValue.
       
  1304                         ].
       
  1305 (argCounter value >= 2) 
       
  1306                 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument2Editor).
       
  1307                         (((self isExpression:tempArgument2Editor) or:[ associationValue isNil])) ifTrue:[                  "looks if an expression is typed in"
       
  1308                                         associationKey:=associationValue printString]
       
  1309                                                           ifFalse:[
       
  1310                                         associationKey:=tempArgument2Editor].
       
  1311 
       
  1312                         tempArguments add: associationKey-> associationValue].
       
  1313 
       
  1314 (argCounter value >= 3)
       
  1315                 ifTrue:[ associationValue:= (Compiler evaluate: tempArgument3Editor).
       
  1316                         ((self isExpression:tempArgument3Editor) or:[ associationValue isNil]) ifTrue:[                  "looks if an expression is typed in"
       
  1317                                         associationKey:=associationValue printString]
       
  1318                                                           ifFalse:[
       
  1319                                         associationKey:=tempArgument3Editor].
       
  1320 
       
  1321                         tempArguments add: associationKey-> associationValue].
       
  1322 
       
  1323 
       
  1324 ^tempArguments
       
  1325 !
       
  1326 
       
  1327 extractClassAndSelectorFrom:anArgument 
       
  1328     "Opens browser on theArgument of a specific class. anArgument being a string with the
       
  1329        Class and the selector upon which the browser is to be opened. Return the receiver."
       
  1330 
       
  1331     |aClass aSelector x theArgument marker|
       
  1332 
       
  1333     anArgument isNil ifTrue:[
       
  1334         ^ nil
       
  1335     ].
       
  1336     marker := self class markerForImplementingClass.
       
  1337 
       
  1338     theArgument := anArgument string withoutPrefix:marker.
       
  1339     aClass := theArgument copyUpTo:(Character space).
       
  1340     x := aClass size + 2.
       
  1341     aSelector := theArgument copyFrom:x.
       
  1342     aClass := Smalltalk classNamed:aClass.
       
  1343     (aSelector startsWith:'class ') ifTrue:[
       
  1344         aSelector := aSelector withoutPrefix:'class '.
       
  1345         aClass := aClass class.
       
  1346     ].
       
  1347     ^ aClass -> aSelector asSymbol
       
  1348 
       
  1349 "
       
  1350 MethodFinderWindow new extractClassAndSelectorFrom: '*SmallInteger +'
       
  1351 MethodFinderWindow new extractClassAndSelectorFrom: 'String ,'       
       
  1352 MethodFinderWindow new extractClassAndSelectorFrom: 'Number detentBy:atMultiplesOf:snap:' 
       
  1353 
       
  1354 
       
  1355 "
       
  1356 
       
  1357     "Modified: / 27-04-2012 / 15:05:53 / cg"
       
  1358 !
       
  1359 
       
  1360 isExpression:aString 
       
  1361     "Return true or false depending on if the subString includes certain characters"
       
  1362     
       
  1363     "/ cg: this is naive - why not ask the parser, if it is a literal?
       
  1364     (aString includesSubString:': ') ifTrue:[
       
  1365         ^ true
       
  1366     ].
       
  1367     (aString includes:$+) ifTrue:[
       
  1368         ^ true
       
  1369     ].
       
  1370     (aString includes:$-) ifTrue:[
       
  1371         ^ true
       
  1372     ].
       
  1373     (aString includes:$*) ifTrue:[
       
  1374         ^ true
       
  1375     ].
       
  1376     (aString includes:$/) ifTrue:[
       
  1377         ^ true
       
  1378     ].
       
  1379     (aString includes:$>) ifTrue:[
       
  1380         ^ true
       
  1381     ].
       
  1382     (aString includes:$<) ifTrue:[
       
  1383         ^ true
       
  1384     ].
       
  1385     (aString includesSubString:' new') ifTrue:[
       
  1386         ^ true
       
  1387     ].
       
  1388     (aString includes:$[) 
       
  1389         & (aString includes:$]) 
       
  1390         & (aString includes:$.) ifTrue:[ ^ false ].
       
  1391 
       
  1392     (aString includes:$.) ifTrue:[
       
  1393         ^ true
       
  1394     ].
       
  1395     ^ false
       
  1396 !
       
  1397 
       
  1398 receiverEditorContents
       
  1399     "Return a cleaned up version of receiver taken from the receiverEditor
       
  1400      as an association. The association has aCleanedRecieverString as a key and the
       
  1401      compiledReceiver as value."
       
  1402     
       
  1403     |aCleanedRecieverString compiledReceiver|
       
  1404 
       
  1405     aCleanedRecieverString := self cleanInputs:(receiverEditor contents).
       
  1406     compiledReceiver := Compiler evaluate:aCleanedRecieverString.
       
  1407     ((self isExpression:aCleanedRecieverString) or:[ compiledReceiver isNil ]) ifTrue:[
       
  1408         aCleanedRecieverString := compiledReceiver printString
       
  1409     ].
       
  1410     ^ aCleanedRecieverString -> compiledReceiver.
       
  1411 !
       
  1412 
       
  1413 waitForBackgroundSearchFinished
       
  1414     | p |
       
  1415 
       
  1416     (p := searchProcess) isNil ifTrue:[^ self].
       
  1417     p isDead ifTrue:[^ self].
       
  1418     p waitUntilTerminated 
       
  1419 ! !
       
  1420 
       
  1421 !MethodFinderWindow methodsFor:'user actions'!
       
  1422 
       
  1423 selectedClassOfResultHolderChanged
       
  1424     |sel classAndSelector mthd|
       
  1425 
       
  1426     sel := self selectedClassOfResultHolder value.
       
  1427 
       
  1428     classAndSelector := self extractClassAndSelectorFrom:sel.
       
  1429     classAndSelector isNil ifTrue:[
       
  1430         ^ self
       
  1431     ].
       
  1432     mthd := classAndSelector key >> classAndSelector value.   
       
  1433     mthd notNil ifTrue:[
       
  1434         self withWaitCursorDo:[
       
  1435             self codeHolder value:mthd source
       
  1436         ]
       
  1437     ] ifFalse:[
       
  1438         self codeHolder value:nil
       
  1439     ].
       
  1440 
       
  1441     "Created: / 13.11.2001 / 12:43:43 / cg"
       
  1442     "Modified: / 13.11.2001 / 12:48:56 / cg"
       
  1443 !
       
  1444 
       
  1445 selectorPatternChanged
       
  1446     self searchPatternMatchesInBackground
       
  1447 
       
  1448     "Created: / 01-06-2012 / 13:18:16 / cg"
  1312 ! !
  1449 ! !
  1313 
  1450 
  1314 !MethodFinderWindow class methodsFor:'documentation'!
  1451 !MethodFinderWindow class methodsFor:'documentation'!
  1315 
  1452 
  1316 version
  1453 version