code cleanup
authorClaus Gittinger <cg@exept.de>
Thu, 22 Mar 2012 07:34:51 +0100
changeset 11452 09f7f34c2d10
parent 11451 b74d43ee586f
child 11453 b34302928a92
code cleanup
SystemBrowser.st
--- a/SystemBrowser.st	Wed Mar 21 17:00:23 2012 +0100
+++ b/SystemBrowser.st	Thu Mar 22 07:34:51 2012 +0100
@@ -2674,34 +2674,9 @@
 browseForSymbol:aSymbol title:title ifNone:actionIfNoneFound searchFor:searchString
     "launch a browser for all methods referencing aSymbol"
 
-    |browser searchBlock sym|
-
-    (aSymbol includesMatchCharacters) ifTrue:[
-        "a matchString"
-        searchBlock := [:c :m :s |
-                            m referencesGlobalMatching:aSymbol
-"/                            (m literalsDetect:[:aLiteral|
-"/                                (aLiteral isMemberOf:Symbol) 
-"/                                  and:[aSymbol match:aLiteral]
-"/                            ] ifNone:nil) notNil
-                       ].
-    ] ifFalse:[
-        "
-         can do a faster search
-        "
-        sym := aSymbol asSymbolIfInterned.
-        sym isNil ifTrue:[
-            actionIfNoneFound value.
-            ^ nil
-        ].
-
-        searchBlock := [:c :m :s |
-                            m referencesGlobal:sym
-"/                            (m literalsDetect:[:aLiteral|
-"/                                (sym == aLiteral) 
-"/                            ] ifNone:nil) notNil
-                       ].
-    ].
+    |browser searchBlock|
+
+    searchBlock := self searchBlockForSymbol:aSymbol.
 
     WarningSignal ignoreIn:[
         InformationSignal ignoreIn:[
@@ -2712,15 +2687,14 @@
         actionIfNoneFound value
     ].
 
-    (browser notNil 
-    and:[searchString notNil]) ifTrue:[
+    (browser notNil and:[searchString notNil]) ifTrue:[
         browser autoSearch:searchString
     ].
     ^ browser
 
-    "Modified: / 24.6.1996 / 14:39:07 / stefan"
-    "Created: / 31.10.1996 / 14:45:08 / cg"
-    "Modified: / 9.11.1999 / 17:04:30 / cg"
+    "Modified: / 24-06-1996 / 14:39:07 / stefan"
+    "Created: / 31-10-1996 / 14:45:08 / cg"
+    "Modified: / 22-03-2012 / 06:58:07 / cg"
 !
 
 browseForSymbol:aSymbol title:title warnIfNone:doWarn
@@ -3849,7 +3823,7 @@
      the classes contained in aCollectionOfClasses and its metaclasses.
      Return a collection of methods"
 
-    |list compare testST testJava lcSelector|
+    |lcSelector list compare testST testJava srchBlockST srchBlockJava|
 
     list := IdentitySet new.
     aSelectorMatchString size == 0 ifTrue:[ ^ list ].
@@ -3870,16 +3844,17 @@
         testJava := [:aSelector :aMethod | (compare value:aSelectorMatchString value:aMethod name) ].
     ].
 
+    srchBlockST := [:sel :mthd | (testST value:sel value:mthd) ifTrue:[ list add:mthd]].
+    srchBlockJava := [:sel :mthd | (testJava value:sel value:mthd) ifTrue:[ list add:mthd]].
+
     aCollectionOfClasses do:[:aClass |
-        |testBlock srchBlock|
+        |srchBlock|
 
         aClass isObsolete ifFalse:[
-            aClass isJavaClass ifTrue:[
-                testBlock := testJava
-            ] ifFalse:[
-                testBlock := testST
-            ].
-            srchBlock := [:sel :mthd | (testBlock value:sel value:mthd) ifTrue:[ list add:mthd]].
+            srchBlock := aClass isJavaClass 
+                            ifTrue:[ srchBlockJava ]
+                            ifFalse:[ srchBlockST ].
+
             aClass methodDictionary keysAndValuesDo:srchBlock.
             aClass isMeta ifFalse:[
                 aClass class methodDictionary keysAndValuesDo:srchBlock
@@ -3890,13 +3865,13 @@
     ^ list
 
     "
-     SystemBrowser findImplementorsOf:#+
-                                     in:(Array with:Number
-                                               with:Float
-                                               with:SmallInteger)
-    "
-
-    "Modified: / 20-09-2007 / 16:02:10 / cg"
+     SystemBrowser 
+        findImplementorsOf:#+
+        in: { Number . Float . SmallInteger }
+        ignoreCase: false
+    "
+
+    "Modified (format): / 22-03-2012 / 07:28:50 / cg"
 !
 
 findImplementors:aSelectorMatchString inMethods:aCollectionOfMethods ignoreCase:ignoreCase match:doMatch
@@ -3952,14 +3927,19 @@
      the classes contained in aCollectionOfClasses and its metaclasses.
      Return a collection of methods"
 
-    ^ self findImplementors:aSelectorMatchString in:aCollectionOfClasses ignoreCase:ignoreCase match:true
-
-    "
-     SystemBrowser findImplementorsOf:#+
-                                     in:(Array with:Number
-                                               with:Float
-                                               with:SmallInteger)
-    "
+    ^ self 
+        findImplementors:aSelectorMatchString 
+        in:aCollectionOfClasses 
+        ignoreCase:ignoreCase 
+        match:true
+
+    "
+     SystemBrowser 
+        findImplementorsOf:#+
+        in:{ Number . Float . SmallInteger }
+    "
+
+    "Modified (comment): / 22-03-2012 / 07:20:42 / cg"
 !
 
 findImplementorsMatchingAny:aCollectionOfSelectors in:aCollectionOfClasses ignoreCase:ignoreCase
@@ -4929,6 +4909,32 @@
      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:false match:true
      SystemBrowser findStringLiteral:'error' in:(Array with:Object) ignoreCase:false match:false
     "
+!
+
+searchBlockForSymbol:aSymbol 
+    "return a matchblock to search for all methods referencing aSymbol"
+
+    (aSymbol includesMatchCharacters) ifTrue:[
+        "a matchString"
+        ^ [:c :m :s |
+                (m literalsDetect:[:aLiteral|
+                        (aLiteral isMemberOf:Symbol) 
+                        and:[aSymbol match:aLiteral]
+                    ] 
+                    ifNone:nil
+                ) notNil
+           ].
+    ] ifFalse:[
+        ^ [:c :m :s |
+                (m literalsDetect:[:aLiteral|
+                    (aSymbol == aLiteral) 
+                    ] 
+                    ifNone:nil
+                ) notNil
+           ].
+    ].
+
+    "Created: / 22-03-2012 / 06:56:51 / cg"
 ! !
 
 !SystemBrowser class methodsFor:'startup'!
@@ -5830,7 +5836,7 @@
 !SystemBrowser class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.299 2012-02-28 11:24:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/SystemBrowser.st,v 1.300 2012-03-22 06:34:51 cg Exp $'
 !
 
 version_SVN