--- a/SystemBrowser.st Fri Jul 14 12:22:07 2000 +0200
+++ b/SystemBrowser.st Fri Jul 14 18:56:27 2000 +0200
@@ -1784,6 +1784,47 @@
ignoreCase:false
"
+!
+
+findString:aString in:aCollectionOfClasses ignoreCase:ignoreCase
+ "return a colelction of all methods in aCollectionOfClasses
+ containing a string in their source.
+ This may be slow, since source-code has to be scanned."
+
+ |browser searchBlock title s|
+
+ (aString includesMatchCharacters
+ or:[ignoreCase]) ifTrue:[
+ s := '*' , aString , '*'.
+ "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 ignoreCase:ignoreCase
+ ]
+ ]
+ ] 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) ~~ 0
+ ]
+ ]
+ ].
+ ^ self findMethodsIn:aCollectionOfClasses where:searchBlock.
+
+ "
+ SystemBrowser findString:'should' in:(Array with:Object) ignoreCase:false
+ "
! !
!SystemBrowser class methodsFor:'startup'!
@@ -2113,49 +2154,9 @@
Processor activeProcess
withPriority:Processor activePriority-1 to:Processor activePriority
do:[
- |checkedClasses checkBlock|
-
- checkedClasses := IdentitySet new.
- list := OrderedCollection new.
-
- checkBlock := [:cls |
- (checkedClasses includes:cls) ifFalse:[
- cls isObsolete ifTrue:[
- Transcript showCR:'skipping obsolete class: ' , cls displayString
- ] ifFalse:[
- cls methodDictionary keysAndValuesDo:[:sel :method |
- (aBlock value:cls value:method value:sel) ifTrue:[
- list add:method "/ (cls name , ' ' , sel)
- ]
- ].
- checkedClasses add:cls.
- ]
- ]
- ].
-
- aCollectionOfClasses do:[:aClass |
- aClass isObsolete ifFalse:[
- "
- output disabled - it slows down things too much (when searching for
- implementors or senders)
- "
- wantInst ifTrue:[
-"/ Transcript show:'searching '; show:aClass name; showCR:' ...'; endEntry.
- checkBlock value:aClass
- ].
- wantClass ifTrue:[
-"/ Transcript show:'searching '; show:aClass class name; showCR:' ...'; endEntry.
- checkBlock value:(aClass class)
- ].
- Processor yield
- ]
- ]
+ list := self findMethodsIn:aCollectionOfClasses inst:wantInst class:wantClass where:aBlock
].
^ self browseMethods:list title:title
-
- "Created: 10.12.1995 / 15:34:57 / cg"
- "Modified: 7.6.1996 / 08:47:54 / stefan"
- "Modified: 15.7.1996 / 11:48:10 / cg"
!
browseMethodsIn:aCollectionOfClasses where:aBlock title:title
@@ -2191,6 +2192,73 @@
title:title
"Modified: 24.1.1997 / 19:44:30 / cg"
+!
+
+browseindMethodsIn:aCollectionOfClasses where:aBlock title:title
+ "find all instance- and classmethods from classes in aCollectionOfClasses,
+ where aBlock evaluates to true.
+ The block is called with 3 arguments, class, method and seelctor."
+
+ ^ self
+ findMethodsIn:aCollectionOfClasses
+ inst:true
+ class:true
+ where:aBlock
+!
+
+findMethodsIn:aCollectionOfClasses inst:wantInst class:wantClass where:aBlock
+ "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|
+
+ checkedClasses := IdentitySet new.
+ list := OrderedCollection new.
+
+ checkBlock := [:cls |
+ (checkedClasses includes:cls) ifFalse:[
+ cls isObsolete ifTrue:[
+ Transcript showCR:'skipping obsolete class: ' , cls displayString
+ ] ifFalse:[
+ cls methodDictionary keysAndValuesDo:[:sel :method |
+ (aBlock value:cls value:method value:sel) ifTrue:[
+ list add:method "/ (cls name , ' ' , sel)
+ ]
+ ].
+ checkedClasses add:cls.
+ ]
+ ]
+ ].
+
+ aCollectionOfClasses do:[:aClass |
+ aClass isObsolete ifFalse:[
+ "
+ output disabled - it slows down things too much (when searching for
+ implementors or senders)
+ "
+ wantInst ifTrue:[
+"/ Transcript show:'searching '; show:aClass name; showCR:' ...'; endEntry.
+ checkBlock value:aClass
+ ].
+ wantClass ifTrue:[
+"/ Transcript show:'searching '; show:aClass class name; showCR:' ...'; endEntry.
+ checkBlock value:(aClass class)
+ ].
+ Processor yield
+ ]
+ ].
+ ^ list
+!
+
+findMethodsIn:aCollectionOfClasses where:aBlock
+ "return all instance- and classmethods
+ from classes in aCollectionOfClasses, where aBlock evaluates to true."
+
+ ^ self
+ findMethodsIn:aCollectionOfClasses
+ inst:true
+ class:true
+ where:aBlock
! !
!SystemBrowser class methodsFor:'startup with query'!
@@ -2251,6 +2319,6 @@
!SystemBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.104 2000-04-28 10:15:55 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.105 2000-07-14 16:56:27 cg Exp $'
! !
SystemBrowser initialize!