MethodFinderWindow.st
changeset 3695 bc4ff07233d7
parent 3685 854b28268aa6
child 3696 530f3998b3a2
equal deleted inserted replaced
3694:33ee2b9869fb 3695:bc4ff07233d7
   179     <resource: #canvas>
   179     <resource: #canvas>
   180 
   180 
   181     ^ 
   181     ^ 
   182     #(FullSpec
   182     #(FullSpec
   183        name: windowSpec
   183        name: windowSpec
   184        uuid: '5fb0c294-89f6-11e9-8df0-b8f6b1108e05'
   184        uuid: '4698b584-a993-11e9-b8a4-b8f6b1108e05'
   185        window: 
   185        window: 
   186       (WindowSpec
   186       (WindowSpec
   187          label: 'MethodFinder'
   187          label: 'MethodFinder'
   188          name: 'MethodFinder'
   188          name: 'MethodFinder'
   189          uuid: '5fb0c87a-89f6-11e9-8df0-b8f6b1108e05'
   189          uuid: '5fb0c87a-89f6-11e9-8df0-b8f6b1108e05'
   506                          doubleClickSelector: openBrowserOn:
   506                          doubleClickSelector: openBrowserOn:
   507                          valueChangeSelector: selectedClassOfResultHolderChanged
   507                          valueChangeSelector: selectedClassOfResultHolderChanged
   508                          useIndex: false
   508                          useIndex: false
   509                          sequenceList: classOfResultHolder
   509                          sequenceList: classOfResultHolder
   510                        )
   510                        )
   511                       (CodeViewSpec
   511                       (ViewSpec
   512                          name: 'CodeView'
   512                          name: 'Box4'
   513                          uuid: '5fb106dc-89f6-11e9-8df0-b8f6b1108e05'
   513                          uuid: '4698d744-a993-11e9-b8a4-b8f6b1108e05'
   514                          model: codeHolder
   514                          component: 
   515                          hasHorizontalScrollBar: true
   515                         (SpecCollection
   516                          hasVerticalScrollBar: true
   516                            collection: (
   517                          autoHideScrollBars: true
   517                             (CodeViewSpec
   518                          hasKeyboardFocusInitially: false
   518                                name: 'CodeView1'
   519                          viewClassName: 'codeViewClass'
   519                                layout: (LayoutFrame 0 0 0 0 0 1 0 1)
   520                          postBuildCallback: sourceCodeWidgetCreated:
   520                                uuid: '5fb106dc-89f6-11e9-8df0-b8f6b1108e05'
       
   521                                model: codeHolder
       
   522                                hasHorizontalScrollBar: true
       
   523                                hasVerticalScrollBar: true
       
   524                                autoHideScrollBars: true
       
   525                                hasKeyboardFocusInitially: false
       
   526                                viewClassName: 'codeViewClass'
       
   527                                postBuildCallback: sourceCodeWidgetCreated:
       
   528                              )
       
   529                             )
       
   530                           
       
   531                          )
   521                        )
   532                        )
   522                       )
   533                       )
   523                     
   534                     
   524                    )
   535                    )
   525                    handles: (Any 0.23999999999999999 1.0)
   536                    handles: (Any 0.5 1.0)
   526                  )
   537                  )
   527                 )
   538                 )
   528               
   539               
   529              )
   540              )
   530              handles: (Any 0.33000000000000002 1.0)
   541              handles: (Any 0.33000000000000002 1.0)
   930                 )
   941                 )
   931                (MenuItem
   942                (MenuItem
   932                   label: '-'
   943                   label: '-'
   933                 )
   944                 )
   934                (MenuItem
   945                (MenuItem
       
   946                   label: 'Show Me How it Works'
       
   947                   itemValue: showMeHowItWorks
       
   948                 )
       
   949                (MenuItem
       
   950                   label: '-'
       
   951                 )
       
   952                (MenuItem
   935                   activeHelpKey: aboutThisAppliaction
   953                   activeHelpKey: aboutThisAppliaction
   936                   label: 'About MethodFinder...'
   954                   label: 'About MethodFinder...'
   937                   itemValue: openAboutThisApplication
   955                   itemValue: openAboutThisApplication
   938                 )
   956                 )
   939                )
   957                )
  1128             mf := MethodFinder new.
  1146             mf := MethodFinder new.
  1129             resultArray := mf
  1147             resultArray := mf
  1130                     load:anArray;
  1148                     load:anArray;
  1131                     findMessage.
  1149                     findMessage.
  1132         ].
  1150         ].
       
  1151         
  1133     ((resultArray at:1) includesSubString:'no single') ifTrue:[
  1152     ((resultArray at:1) includesSubString:'no single') ifTrue:[
  1134         self warn:(resultArray at:1).
  1153         false ifTrue:[
       
  1154             (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' bindWith:(resultArray at:1)))
       
  1155             ifTrue:[
       
  1156                 self search2Levels.
       
  1157             ]. 
       
  1158         ] ifFalse:[
       
  1159             self warn:(resultArray at:1).
       
  1160         ].    
  1135         ^ self
  1161         ^ self
  1136     ].
  1162     ].
  1137      "the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
  1163     
       
  1164     "the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
  1138     resultArray
  1165     resultArray
  1139         keysAndValuesDo:[:key :value |
  1166         keysAndValuesDo:[:key :value |
  1140             |newValue|
  1167             |newValue|
  1141 
  1168 
  1142             newValue := value copyReplaceString:'data1' 
  1169             newValue := value copyReplaceString:'data1' 
  1165     resultSelectors := mf selectors.
  1192     resultSelectors := mf selectors.
  1166     receiver := tempReceiver
  1193     receiver := tempReceiver
  1167 
  1194 
  1168     "Modified: / 26-09-2011 / 12:42:28 / cg"
  1195     "Modified: / 26-09-2011 / 12:42:28 / cg"
  1169     "Modified: / 27-02-2018 / 11:37:58 / stefan"
  1196     "Modified: / 27-02-2018 / 11:37:58 / stefan"
  1170     "Modified: / 08-06-2019 / 16:24:00 / Claus Gittinger"
  1197     "Modified: / 18-07-2019 / 21:57:12 / Claus Gittinger"
       
  1198 !
       
  1199 
       
  1200 search2Levels
       
  1201     "Do an exhaustive search.
       
  1202      Given the original message,
       
  1203      try applying all unary messages first to the receiver,
       
  1204      then to each argument.
       
  1205      This takes O(N^2) time - so be prepared"
       
  1206 
       
  1207     |tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf|
       
  1208 
       
  1209     tempArguments := self argumentEditorsContents.
       
  1210     tempReceiver := self receiverEditorContents.
       
  1211     tempAnswer := self messageAnswerEditorContents.
       
  1212 
       
  1213     anArray := Array new:2.
       
  1214     receiverWithArgument := self mergeReceiver:(tempReceiver value)
       
  1215                                  withArgument:(tempArguments values).
       
  1216     anArray
       
  1217         at:1 put:receiverWithArgument;
       
  1218         at:2 put:tempAnswer value.
       
  1219     "an array now holds the following array #(#(receiver argument) answer) or #(#(receiver) answer). 
       
  1220      which should be suitable input for the method finder."
       
  1221     self withCursor:Cursor execute do:[
       
  1222         mf := MethodFinder new.
       
  1223         resultArray := mf load:anArray; findMessage.
       
  1224     ].
       
  1225         
       
  1226     ((resultArray at:1) includesSubString:'no single') ifTrue:[
       
  1227         (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' bindWith:(resultArray at:1)))
       
  1228         ifTrue:[
       
  1229             self search2Levels.
       
  1230         ].    
       
  1231         ^ self
       
  1232     ].
       
  1233     
       
  1234     "the following then replaces data1 and data2 created by the method finder to the appropriate arguments"
       
  1235     resultArray
       
  1236         keysAndValuesDo:[:key :value |
       
  1237             |newValue|
       
  1238 
       
  1239             newValue := value copyReplaceString:'data1' 
       
  1240                               withString:(tempReceiver value storeString). "/ was: "tempReceiver key" 
       
  1241             (tempArguments size) >= 1 ifTrue:[
       
  1242                 newValue := newValue copyReplaceString:'data2'
       
  1243                                      withString:(tempArguments valueAt:1) storeString "/ was "keyAt:1" 
       
  1244             ].
       
  1245             (tempArguments size) > 1 ifTrue:[
       
  1246                 newValue := newValue copyReplaceString:'data3'
       
  1247                                      withString:(tempArguments valueAt:2) storeString. "/ was "keyAt:2" 
       
  1248             ].
       
  1249             (tempArguments size) > 2 ifTrue:[
       
  1250                 newValue := newValue copyReplaceString:'data4'
       
  1251                                      withString:(tempArguments valueAt:3) storeString. "/ was: keyAt:3
       
  1252             ].
       
  1253             (tempArguments size) > 3 ifTrue:[
       
  1254                 self halt:'unimplemented'.
       
  1255             ].
       
  1256              "    newValue:= value copyReplaceString: 'data3' withString:(self messageAnswer key). "
       
  1257             newValue := newValue , ' --> ' , (tempAnswer key).
       
  1258             newValue replaceAll:Character cr with:Character space.
       
  1259             resultArray at:key put:newValue.
       
  1260         ].
       
  1261     self resultHolder value:resultArray.
       
  1262     resultSelectors := mf selectors.
       
  1263     receiver := tempReceiver
       
  1264 
       
  1265     "Created: / 18-07-2019 / 21:22:47 / Claus Gittinger"
  1171 !
  1266 !
  1172 
  1267 
  1173 searchPatternMatchesInBackground
  1268 searchPatternMatchesInBackground
  1174     "Do a search based on the pattern match as a background task"
  1269     "Do a search based on the pattern match as a background task"
  1175 
  1270