SystemBrowser.st
changeset 18982 b122ce4e6e60
parent 18900 8568425e77d1
child 19026 7325161dbede
equal deleted inserted replaced
18981:1cf50cec3108 18982:b122ce4e6e60
  5996 
  5996 
  5997 searchBlockForString:aString ignoreCase:ignoreCase match:doMatchArg fullWordsOnly:fullWordsOnly resourceMethodsOnly:resourceMethodsOnly
  5997 searchBlockForString:aString ignoreCase:ignoreCase match:doMatchArg fullWordsOnly:fullWordsOnly resourceMethodsOnly:resourceMethodsOnly
  5998     "return a block to search for a string."
  5998     "return a block to search for a string."
  5999 
  5999 
  6000     |checkBlock lineCheckBlock pattern doMatch
  6000     |checkBlock lineCheckBlock pattern doMatch
  6001      quickCheckString firstMatchIndex lastMatchIndex stringSearchBlock|
  6001      quickCheckString firstMatchIndex lastMatchIndex stringSearchBlock
       
  6002      caseSensitive|
       
  6003 
       
  6004     caseSensitive := ignoreCase not.
  6002 
  6005 
  6003     doMatch := doMatchArg.
  6006     doMatch := doMatchArg.
  6004     aString includesMatchCharacters ifFalse:[
  6007     aString includesMatchCharacters ifFalse:[
  6005         doMatch := false.
  6008         doMatch := false.
  6006     ].    
  6009     ].    
  6024         ].    
  6027         ].    
  6025         aString last == $* ifFalse:[
  6028         aString last == $* ifFalse:[
  6026             pattern := pattern,'*'
  6029             pattern := pattern,'*'
  6027         ].
  6030         ].
  6028         "/ when doing a match, be careful to not match acrosss lines
  6031         "/ when doing a match, be careful to not match acrosss lines
  6029         lineCheckBlock := [:line | pattern match:line caseSensitive:ignoreCase not].
  6032         lineCheckBlock := [:line | pattern match:line caseSensitive:caseSensitive].
  6030         quickCheckString size > 1 ifTrue:[
  6033         quickCheckString size > 1 ifTrue:[
  6031             checkBlock := [:src | 
  6034             checkBlock := [:src | 
  6032                             (src includesString:quickCheckString caseSensitive:ignoreCase not)
  6035                             (src includesString:quickCheckString caseSensitive:caseSensitive)
  6033                             and:[ (lineCheckBlock value:src)
  6036                             and:[ (lineCheckBlock value:src)
  6034                             and:[ src asStringCollection contains:lineCheckBlock ]]].
  6037                             and:[ src asStringCollection contains:lineCheckBlock ]]].
  6035         ] ifFalse:[    
  6038         ] ifFalse:[    
  6036             checkBlock := [:src | 
  6039             checkBlock := [:src | 
  6037                             (lineCheckBlock value:src)
  6040                             (lineCheckBlock value:src)
  6038                             and:[ src asStringCollection contains:lineCheckBlock ]].
  6041                             and:[ src asStringCollection contains:lineCheckBlock ]].
  6039         ].
  6042         ].
  6040     ] ifFalse:[
  6043     ] ifFalse:[
  6041         checkBlock := [:src | src includesString:aString caseSensitive:ignoreCase not]
  6044         "a regular string"
       
  6045         "/ because caseInsensitive searches are slower,
       
  6046         "/ check if we can also compare caseInsensitive (i.e. there are no letters in it)
       
  6047         (caseSensitive or:[aString conform:[:ch | ch isNationalLetter not]]) ifTrue:[
       
  6048             checkBlock := [:src | 
       
  6049                 (src indexOfSubCollection:aString startingAt:1 ifAbsent:0 caseSensitive:true) ~~ 0 
       
  6050             ]
       
  6051         ] ifFalse:[
       
  6052             checkBlock := [:src | 
       
  6053                 (src indexOfSubCollection:aString startingAt:1 ifAbsent:0 caseSensitive:false) ~~ 0 
       
  6054             ]
       
  6055         ].
  6042     ].
  6056     ].
  6043     
  6057     
  6044     stringSearchBlock :=
  6058     stringSearchBlock :=
  6045         [:cls :mthd :sel | 
  6059         [:cls :mthd :sel | 
  6046             |src found idx1 reallyFound ch1 ch2|
  6060             |src found idx1 reallyFound ch1 ch2|
  6059                         reallyFound := false.
  6073                         reallyFound := false.
  6060                         idx1 := 0.
  6074                         idx1 := 0.
  6061                         [ 
  6075                         [ 
  6062                             reallyFound not
  6076                             reallyFound not
  6063                             and:[
  6077                             and:[
  6064                                 idx1 := src indexOfSubCollection:aString startingAt:idx1+1 ifAbsent:0 caseSensitive:ignoreCase not.
  6078                                 idx1 := src indexOfSubCollection:aString startingAt:idx1+1 ifAbsent:0 caseSensitive:caseSensitive.
  6065                                 idx1 ~~ 0]
  6079                                 idx1 ~~ 0]
  6066                         ] whileTrue:[
  6080                         ] whileTrue:[
  6067                             "/ see if it is a free-standing word
  6081                             "/ see if it is a free-standing word
  6068                             reallyFound := true.
  6082                             reallyFound := true.
  6069                             idx1 > 1 ifTrue:[
  6083                             idx1 > 1 ifTrue:[