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| |