Tools__MethodRewriter.st
changeset 18154 c4719a869809
parent 18150 a78b9b9ca7e4
child 18391 84485dc3aeb8
equal deleted inserted replaced
18153:de80965bf770 18154:c4719a869809
  1247     "Modified: / 22-03-2012 / 18:23:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1247     "Modified: / 22-03-2012 / 18:23:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1248     "Modified: / 24-05-2018 / 14:35:06 / Claus Gittinger"
  1248     "Modified: / 24-05-2018 / 14:35:06 / Claus Gittinger"
  1249 !
  1249 !
  1250 
  1250 
  1251 doSearchAction
  1251 doSearchAction
  1252     |ruleName|
  1252     |ruleName searchPattern|
  1253 
  1253 
  1254     ruleForRewriteOrNilForAdHoc notNil ifTrue:[
  1254     ruleForRewriteOrNilForAdHoc notNil ifTrue:[
  1255         ruleName := self selectedRule name.
  1255         ruleName := self selectedRule name.
  1256         
  1256         
  1257         self
  1257         self
  1258             doSearchRule: self selectedRule
  1258             doSearchRule: self selectedRule
  1259             withResultDo:[:matchingMethods|
  1259             withResultDo:[:matchingMethods|
       
  1260                 |brwsr searchStrings|
       
  1261                 
  1260                 matchingMethods isEmpty
  1262                 matchingMethods isEmpty
  1261                     ifTrue:[
  1263                     ifTrue:[
  1262                         Dialog warn:(resources 
  1264                         Dialog warn:(resources 
  1263                                         string:'No methods found by rule: "%1"'
  1265                                         string:'No methods found by rule: "%1"'
  1264                                         with:ruleName)
  1266                                         with:ruleName)
  1265                     ]
  1267                     ]
  1266                     ifFalse:[
  1268                     ifFalse:[
  1267                         self
  1269                         brwsr := self
  1268                             showMethods: matchingMethods asArray
  1270                             showMethods: matchingMethods asArray
  1269                             title: (resources 
  1271                             title: (resources 
  1270                                         string:'%1 Methods matching rule: "%2"'
  1272                                         string:'%1 Methods matching rule: "%2"'
  1271                                         with:matchingMethods size
  1273                                         with:matchingMethods size
  1272                                         with:ruleName)
  1274                                         with:ruleName).
       
  1275                         searchStrings := self selectedRule rewriteRule searches collect:[:eachSearch | eachSearch searchString].
       
  1276                         brwsr autoSearchCodePatterns:searchStrings
       
  1277 
  1273                     ]
  1278                     ]
  1274             ]
  1279             ]
  1275     ] ifFalse:[
  1280     ] ifFalse:[
  1276        self
  1281         searchPattern := self searchPattern.      
  1277             doSearchPattern: self searchPattern
  1282         self
       
  1283             doSearchPattern:searchPattern
  1278             withResultDo:[:matchingMethods|
  1284             withResultDo:[:matchingMethods|
       
  1285                 |brwsr|
       
  1286                 
  1279                 matchingMethods isEmpty
  1287                 matchingMethods isEmpty
  1280                     ifTrue:[
  1288                     ifTrue:[
  1281                         Dialog warn:(resources 
  1289                         Dialog warn:(resources 
  1282                                         string:'No methods found for search pattern "%1"'
  1290                                         string:'No methods found for search pattern "%1"'
  1283                                         with: self searchPattern)
  1291                                         with:searchPattern)
  1284                     ]
  1292                     ]
  1285                     ifFalse:[
  1293                     ifFalse:[
  1286                         self
  1294                         brwsr := self
  1287                             showMethods: matchingMethods asArray
  1295                             showMethods:matchingMethods asArray
  1288                             title:(resources 
  1296                             title:(resources 
  1289                                     string:'%1 Methods matching "%2"'
  1297                                     string:'%1 Methods matching "%2"'
  1290                                     with:matchingMethods size
  1298                                     with:matchingMethods size
  1291                                     with: self searchPattern)
  1299                                     with:searchPattern).
       
  1300                         self halt. brwsr autoSearchCodePattern:searchPattern            
  1292                     ]
  1301                     ]
  1293             ]
  1302             ]
  1294     ]
  1303     ]
  1295 
  1304 
  1296     "Created: / 12-12-2007 / 11:14:25 / janfrog"
  1305     "Created: / 12-12-2007 / 11:14:25 / janfrog"
  1297     "Modified: / 24-05-2018 / 14:28:39 / Claus Gittinger"
  1306     "Modified: / 24-05-2018 / 20:44:46 / Claus Gittinger"
  1298 !
  1307 !
  1299 
  1308 
  1300 removeSeletedClassesAction
  1309 removeSeletedClassesAction
  1301     |toRemove|
  1310     |toRemove|
  1302 
  1311 
  1811 !
  1820 !
  1812 
  1821 
  1813 showMethods: methods title: title
  1822 showMethods: methods title: title
  1814     "open a browser on matching methods"
  1823     "open a browser on matching methods"
  1815     
  1824     
  1816     SystemBrowser default
  1825     ^ SystemBrowser default
  1817                 browseMethods:methods
  1826                 browseMethods:methods
  1818                 title:title
  1827                 title:title
  1819                 sort:true
  1828                 sort:true
  1820 
  1829 
  1821     "Created: / 21-07-2007 / 06:51:36 / janfrog"
  1830     "Created: / 21-07-2007 / 06:51:36 / janfrog"
  1822     "Modified: / 24-05-2018 / 14:34:16 / Claus Gittinger"
  1831     "Modified: / 24-05-2018 / 20:27:46 / Claus Gittinger"
  1823 !
  1832 !
  1824 
  1833 
  1825 withMethods: givenMethods do: methodBlock
  1834 withMethods: givenMethods do: methodBlock
  1826 
  1835 
  1827     ^self withMethods: givenMethods do: methodBlock finallyDo: []
  1836     ^self withMethods: givenMethods do: methodBlock finallyDo: []
  1842         methods asArray keysAndValuesDo:[:idx :mth|
  1851         methods asArray keysAndValuesDo:[:idx :mth|
  1843             |mclass|
  1852             |mclass|
  1844 
  1853 
  1845             mclass := mth mclass.
  1854             mclass := mth mclass.
  1846             mclass isNil ifTrue:[
  1855             mclass isNil ifTrue:[
  1847                 Transcript showCR:'method no longer valid in ',mth getMclass printString.
  1856                 Transcript showCR:'previously found method is no longer valid in ',mth getMclass printString.
  1848             ] ifFalse:[    
  1857             ] ifFalse:[    
  1849                 numMethods > 100 ifTrue:[
  1858                 numMethods > 100 ifTrue:[
  1850                     self info: mclass name.
  1859                     self info: mclass name.
  1851                 ] ifFalse:[
  1860                 ] ifFalse:[
  1852                     self info: mth selector storeString.
  1861                     self info: mth selector storeString.
  1861         self progress: 0.
  1870         self progress: 0.
  1862         self info: ''
  1871         self info: ''
  1863     ]
  1872     ]
  1864 
  1873 
  1865     "Created: / 12-12-2007 / 10:32:16 / janfrog"
  1874     "Created: / 12-12-2007 / 10:32:16 / janfrog"
       
  1875     "Modified: / 24-05-2018 / 18:23:17 / Claus Gittinger"
  1866 !
  1876 !
  1867 
  1877 
  1868 withMethodsDo: methodBlock finallyDo: finallyBlock
  1878 withMethodsDo: methodBlock finallyDo: finallyBlock
  1869 
  1879 
  1870    ^self
  1880    ^self