diff -r 6bc184e74f9c -r 85d703589d34 SystemBrowser.st --- a/SystemBrowser.st Thu May 05 06:48:38 2016 +0200 +++ b/SystemBrowser.st Fri May 06 06:55:08 2016 +0200 @@ -2594,7 +2594,9 @@ !SystemBrowser class methodsFor:'special search startup'! allCallsOn:aSelectorString - "return a collection of methods which send aSelector." + "return a collection of methods which send aSelector. + This takes some time, because source code is parsed to see + if there is really a message send inside (and not just a symbol reference)" ^ self allCallsOn:aSelectorString @@ -2603,7 +2605,9 @@ match:false " - SystemBrowser allCallsOn:#at:put: + Time millisecondsToRun:[ + SystemBrowser allCallsOn:#at:put: + ]. " "Created: 24.1.1997 / 19:42:57 / cg" @@ -5666,103 +5670,100 @@ "Modified: / 24-07-2011 / 09:50:30 / cg" ! -searchBlockForString:aString ignoreCase:ignoreCase match:doMatch +searchBlockForString:aString ignoreCase:ignoreCase match:doMatchArg "return a block to search for a string." - |searchBlock s lcString| - - (doMatch and:[ aString includesMatchCharacters ]) ifTrue:[ - s := '*' , aString , '*'. + |checkBlock pattern doMatch| + + doMatch := doMatchArg. + aString includesMatchCharacters ifFalse:[ + doMatch := false. + ]. + doMatch ifTrue:[ "a matchString" - searchBlock := [:c :m :sel | - |src| - src := m source. - src isNil ifTrue:[ - ('Browser [info]: no source for ' , m printString) infoPrintCR. - false - ] ifFalse:[ - s match:src caseSensitive:ignoreCase not - ] - ] + pattern := aString. + aString first == $* ifFalse:[ + pattern := '*',pattern + ]. + aString last == $* ifFalse:[ + pattern := pattern,'*' + ]. + ignoreCase ifTrue:[ + checkBlock := [:src | pattern match:src caseSensitive:false] + ] ifFalse:[ + checkBlock := [:src | pattern match:src caseSensitive:true] + ] ] ifFalse:[ ignoreCase ifTrue:[ - lcString := aString asLowercase. - searchBlock := - [:c :m :sel | - |src| - - src := m source. - src isNil ifTrue:[ - ('Browser [info]: no source for ' , m printString) infoPrintCR. - false - ] ifFalse:[ - (src asLowercase findString:lcString caseSensitive:true) ~~ 0 - ] - ] + checkBlock := [:src | src includesString:aString caseSensitive:false] ] ifFalse:[ - searchBlock := - [:c :m :sel | - |src| - - src := m source. - src isNil ifTrue:[ - ('Browser [info]: no source for ' , m printString) infoPrintCR. - false - ] ifFalse:[ - (src findString:aString caseSensitive:ignoreCase not) ~~ 0 - ] - ] - ]. + checkBlock := [:src | src includesString:aString caseSensitive:true] + ]. ]. - ^ searchBlock. + ^ [:cls :mthd :sel | + |src| + + src := mthd source. + src isNil ifTrue:[ + ('Browser [info]: no source for ' , mthd printString) infoPrintCR. + false + ] ifFalse:[ + checkBlock value:src + ] + ] " SystemBrowser findString:'should' in:(Array with:Object) ignoreCase:false " ! -searchBlockForStringLiteral:aString ignoreCase:ignoreCase match:doMatch +searchBlockForStringLiteral:aString ignoreCase:ignoreCase match:doMatchArg "return a block to search for a string-literal." - |searchBlock s| - - (doMatch and:[ aString includesMatchCharacters]) ifTrue:[ - s := '*' , aString , '*'. + |pattern s doMatch checkLiteral| + + aString isEmpty ifTrue:[^ [:cls :mthd :sel | true ]]. + + doMatch := doMatchArg. + (aString includesMatchCharacters) ifFalse:[ + doMatch := false + ]. + doMatch ifTrue:[ "a matchString" - searchBlock := [:c :m :sel | - |lits| - lits := m literals ? #(). - lits contains:[:lit | - lit isString - and:[lit isSymbol not - and:[s match:lit caseSensitive:ignoreCase not]] - ] - ] + pattern := aString. + aString first == $* ifFalse:[ + pattern := '*',pattern + ]. + aString last == $* ifFalse:[ + pattern := pattern,'*' + ]. + checkLiteral := + [:lit | + lit isString + and:[lit isSymbol not + and:[s match:lit caseSensitive:ignoreCase not]] + ] ] ifFalse:[ ignoreCase ifTrue:[ - s := aString asLowercase. - searchBlock := [:c :m :sel | - |lits| - lits := m literals ? #(). - lits contains:[:lit | - lit isString - and:[lit isSymbol not - and:[s = lit asLowercase]] - ] - ] + checkLiteral := + [:lit | + lit isString + and:[lit isSymbol not + and:[lit includesString:aString caseSensitive:true]] + ] ] ifFalse:[ - searchBlock := [:c :m :sel | - |lits| - lits := m literals ? #(). - lits contains:[:lit | - lit isString - and:[lit isSymbol not - and:[s = lit]] - ] - ] - ]. + checkLiteral := + [:lit | + lit isString + and:[lit isSymbol not + and:[lit includesString:aString]] + ] + ]. ]. - ^ searchBlock. + + ^ [:cls :mthd :sel | + (mthd literalsDetect:checkLiteral ifNone:[nil]) notNil + ] " SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:true match:true @@ -6280,7 +6281,8 @@ "return all instance- (if wantInst is true) and/or classmethods (if wantClass is true) from classes in aCollectionOfClasses, where aBlock evaluates to true." - |list checkedClasses checkBlock nClasses nClassesDone oldPercentage newPercentage| + |list checkedClasses checkBlock nClasses + nClassesDone oldPercentage newPercentage nClassesSinceLastPercentage bulkSize| checkedClasses := IdentitySet new. list := OrderedCollection new. @@ -6311,9 +6313,13 @@ nClasses := aCollectionOfClasses size. nClassesDone := 0. oldPercentage := 0. + nClassesSinceLastPercentage := 0. + bulkSize := (nClasses // 30) max:10. "/ roughly every 3%. aCollectionOfClasses do:[:aClass | (aClass notNil and:[aClass isObsolete not]) ifTrue:[ + nClassesSinceLastPercentage := nClassesSinceLastPercentage + 1. + " output disabled - it slows down things too much (when searching for implementors or senders) @@ -6326,13 +6332,14 @@ "/ Transcript show:'searching '; show:aClass class name; showCR:' ...'; endEntry. checkBlock value:(aClass class) ]. - nClassesDone > 5 ifTrue:[ + nClassesSinceLastPercentage > bulkSize ifTrue:[ "/ Processor yield newPercentage := nClassesDone * 100 // nClasses. newPercentage ~= oldPercentage ifTrue:[ ProgressNotification progressPercentage:newPercentage. oldPercentage := newPercentage. ]. + nClassesSinceLastPercentage := 0. ]. ]. nClassesDone := nClassesDone + 1.