--- a/SystemBrowser.st Mon Oct 19 16:35:24 2009 +0200
+++ b/SystemBrowser.st Tue Oct 20 09:46:39 2009 +0200
@@ -3205,76 +3205,29 @@
!
browseReferendsOf:aGlobalName title:title ifNone:actionIfNone
- "launch a browser for all methods referencing a global
- named aGlobalName.
- "
-
- |globalsPlainName idx searchBlock
- sym browser matchingGlobalNames|
-
- globalsPlainName := aGlobalName.
- (idx := globalsPlainName lastIndexOf:$:) ~~ 0 ifTrue:[
- globalsPlainName := globalsPlainName copyFrom:idx+1.
- (globalsPlainName size == 0
- or:[globalsPlainName = '*']) ifTrue:[
- globalsPlainName := aGlobalName
- ]
- ].
-
- matchingGlobalNames := OrderedCollection new.
-
- (sym := aGlobalName asSymbolIfInterned) notNil ifTrue:[
- matchingGlobalNames add:sym.
- searchBlock := [:cls :mthd :sel | |mSource|
- "/ kludge: Lazy methods do not include symbols in the literal array - sigh
- mthd isLazyMethod ifTrue:[
- mSource := mthd source.
- (mSource notNil
- and:[(mSource includesString:sym)
- and:[mthd usedGlobals includes:sym]])
- ] ifFalse:[
- ((mthd refersToLiteral:sym)
- and:[mthd usedGlobals includes:sym])
- ]
- ]
- ] ifFalse:[
- aGlobalName includesMatchCharacters ifFalse:[
- actionIfNone value.
- ^ nil
- ].
- searchBlock := [:cls :mthd :sel | |mSource usedGlobals global|
- "/ kludge: Lazy methods do not include symbols in the literal array - sigh
- mthd isLazyMethod ifTrue:[
- mSource := mthd source.
- mSource notNil ifTrue:[
- usedGlobals := mthd usedGlobals
- ]
- ] ifFalse:[
- (mthd literals contains:[:lit | aGlobalName match:lit]) ifTrue:[
- usedGlobals := mthd usedGlobals
- ].
- ].
- usedGlobals notNil ifTrue:[
- global := usedGlobals detect:[:lit | aGlobalName match:lit] ifNone:nil.
- global notNil ifTrue:[
- matchingGlobalNames add:global.
- ]
- ].
- global notNil
- ]
- ].
- "/ WarningSignal ignoreIn:[
- "/ InformationSignal ignoreIn:[
- browser := self browseMethodsWhere:searchBlock title:title ifNone:[actionIfNone value. ^ nil].
- "/ ].
- "/ ].
+ "launch a browser for all methods referencing a global named aGlobalName."
+
+ |searchBlock browser|
+
+ searchBlock := self searchBlockForReferendsOf:aGlobalName.
+ browser := self
+ browseMethodsWhere:searchBlock
+ title:title
+ ifNone:[
+ actionIfNone value.
+ ^ nil
+ ].
+
browser isNil ifTrue:[
actionIfNone value
] ifFalse:[
- browser autoSearchVariables:matchingGlobalNames readers:true writers:true.
- "/ browser autoSearch:globalsPlainName.
+ browser autoSearchVariables:(Array with:aGlobalName) readers:true writers:true.
].
^ browser
+
+ "
+ Tools::NewSystemBrowser browseReferendsOf:'SortedCollection' title:'foo' ifNone:[ self halt ]
+ "
!
browseReferendsOf:aGlobalName title:title warnIfNone:doWarn
@@ -4567,6 +4520,68 @@
"Modified: / 12-10-2006 / 21:30:05 / cg"
!
+searchBlockForReferendsOf:aGlobalName
+ "return a block which searches for all methods which reference a global named aGlobalName,
+ which may be a matchpattern"
+
+ |globalsPlainName idx matchingGlobalNames|
+
+ globalsPlainName := aGlobalName.
+ (idx := globalsPlainName lastIndexOf:$:) ~~ 0 ifTrue:[
+ globalsPlainName := globalsPlainName copyFrom:idx+1.
+ (globalsPlainName size == 0
+ or:[globalsPlainName = '*']) ifTrue:[
+ globalsPlainName := aGlobalName
+ ]
+ ].
+
+ matchingGlobalNames := OrderedCollection new.
+
+ aGlobalName includesMatchCharacters ifFalse:[
+ ^ [:cls :mthd :sel |
+ |sym mSource|
+
+ (sym := aGlobalName asSymbolIfInterned) isNil ifTrue:[
+ false
+ ] ifFalse:[
+ "/ kludge: Lazy methods do not include symbols in the literal array - sigh
+ mthd isLazyMethod ifTrue:[
+ mSource := mthd source.
+ (mSource notNil
+ and:[(mSource includesString:sym)
+ and:[mthd usedGlobals includes:sym]])
+ ] ifFalse:[
+ ((mthd refersToLiteral:sym)
+ and:[mthd usedGlobals includes:sym])
+ ]
+ ]
+ ].
+ ].
+
+ ^ [:cls :mthd :sel |
+ |mSource usedGlobals global|
+
+ "/ kludge: Lazy methods do not include symbols in the literal array - sigh
+ mthd isLazyMethod ifTrue:[
+ mSource := mthd source.
+ mSource notNil ifTrue:[
+ usedGlobals := mthd usedGlobals
+ ]
+ ] ifFalse:[
+ (mthd literals contains:[:lit | aGlobalName match:lit]) ifTrue:[
+ usedGlobals := mthd usedGlobals
+ ].
+ ].
+ usedGlobals notNil ifTrue:[
+ global := usedGlobals detect:[:lit | aGlobalName match:lit] ifNone:nil.
+ global notNil ifTrue:[
+ matchingGlobalNames add:global.
+ ]
+ ].
+ global notNil
+ ].
+!
+
searchBlockForString:aString ignoreCase:ignoreCase match:doMatch
"return a block to search for a string."
@@ -5529,11 +5544,11 @@
!SystemBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.271 2009-10-07 13:55:17 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.272 2009-10-20 07:46:39 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.271 2009-10-07 13:55:17 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.272 2009-10-20 07:46:39 cg Exp $'
! !
SystemBrowser initialize!