askForClassNameMatching fixed for private classes
authortm
Thu, 18 Oct 2001 11:22:39 +0200
changeset 3317 f67c198a61e0
parent 3316 c4930be8576c
child 3318 46c3347385f4
askForClassNameMatching fixed for private classes
NewSystemBrowser.st
Tools__NewSystemBrowser.st
--- a/NewSystemBrowser.st	Wed Oct 17 15:47:06 2001 +0200
+++ b/NewSystemBrowser.st	Thu Oct 18 11:22:39 2001 +0200
@@ -20966,7 +20966,14 @@
     className isNil ifTrue:[^ self "cancel"].
 
     singleClass ifTrue:[
-        className := self askForClassNameMatching:className.
+        className includesMatchCharacters ifFalse:[
+            class := Smalltalk at:className asSymbol.
+            class isNil ifTrue:[
+                ^ self warn:'No such class'.
+            ].
+        ] ifTrue:[
+            className := self askForClassNameMatching:className.
+        ].
         className notNil ifTrue:[
             doWhat == #newBrowser ifTrue:[
                 brwsr := self class new.
@@ -20994,7 +21001,7 @@
             classes := classes asOrderedCollection.
         ].
         classes size == 0 ifTrue:[
-            ^ self warn:'no className matches'.
+            ^ self warn:'No className matches'.
         ].
         doWhat isNil ifTrue:[
             "/ select them ...
@@ -24894,18 +24901,27 @@
      substringMatchingNames caselessSubstringMatchingNames
      caselessWithoutPrefixSubstringMatchingNames
      lcMatchString subMatch lcSubMatch box className
-     needSearch cls env pref aMatchString allNames sortedBySpellingDistance|
+     needSearch cls env searchBlock
+     idx pref aMatchString allNames sortedBySpellingDistance|
 
     env := self navigationState environment.
 
     aMatchString := matchStringArg.
 
+    "/ try to limit search to a namespace (but only if nameSpace is not a matchCharacter)
+
     (aMatchString includesString:'::') ifTrue:[
-        pref := aMatchString upTo:$:.
-        cls := Smalltalk at:pref asSymbol ifAbsent:nil.
-        (cls notNil and:[cls isBehavior]) ifTrue:[
-            env := cls.
-            aMatchString := aMatchString copyFrom:pref size + 1 + 2.
+        "/ pref := aMatchString upTo:$:.       
+        idx := aMatchString lastIndexOf:$:.
+        pref := aMatchString copyTo:idx-2.
+        pref includesMatchCharacters ifTrue:[
+            "/ search all in Smalltalk
+        ] ifFalse:[
+            cls := Smalltalk at:pref asSymbol ifAbsent:nil.
+            (cls notNil and:[cls isBehavior]) ifTrue:[
+                env := cls.
+                aMatchString := aMatchString copyFrom:pref size + 1 + 2.
+            ].
         ].
     ].
 
@@ -24936,7 +24952,7 @@
     ].
 
     needSearch ifTrue:[
-        env allClassesDo:[:aClass |
+        searchBlock := [:aClass |
             |thisName|
 
             "/ to make it look better,
@@ -24948,10 +24964,14 @@
             ] ifFalse:[
                 thisName := aClass name
             ].
-
-            (lcMatchString match:aClass nameWithoutPrefix asLowercase) ifTrue:[
+            (lcMatchString match:aClass name asLowercase) ifTrue:[
                 caselessWithoutPrefixSubstringMatchingNames add:thisName
             ].
+            aClass nameWithoutPrefix ~= aClass name ifTrue:[
+                (lcMatchString match:aClass nameWithoutPrefix asLowercase) ifTrue:[
+                    caselessWithoutPrefixSubstringMatchingNames add:thisName
+                ].
+            ].
 
             (aMatchString match:thisName) ifTrue:[
                 classNames add:thisName
@@ -24972,6 +24992,12 @@
             ]
         ].
 
+        (env == Smalltalk or:[env isNamespace]) ifTrue:[
+            env allClassesDo:searchBlock
+        ] ifFalse:[
+            env allPrivateClasses do:searchBlock
+        ].
+
         sortedBySpellingDistance := false.
 
         "/ if nothing matched - try caseless matches
@@ -25028,6 +25054,9 @@
             ].
             box action:[:aString | className := aString].
             box open.
+            className isNil ifTrue:[ "/ cancel
+                ^ nil
+            ]
         ].
     ].
 
@@ -25038,9 +25067,9 @@
         ].
     ].
 
-    pref notNil ifTrue:[
-        ^ pref , '::' , className
-    ].
+"/    pref notNil ifTrue:[
+"/        ^ pref , '::' , className
+"/    ].
     ^ className
 
     "Modified: / 13.2.2000 / 20:57:42 / cg"
@@ -30568,7 +30597,7 @@
 !
 
 methodDoubleClicked:aMethod
-    |resources editorClass "brwsr" mSelector mClass|
+    |resources editorClass brwsr mSelector mClass|
 
     mSelector := aMethod selector.
     mClass := aMethod mclass.
@@ -30628,9 +30657,9 @@
     "/
     "/ double clicking on any other method adds a senders buffer
     "/
-    self 
-        spawnMethodSendersBrowserFor:(Array with:mSelector) 
-        in:#newBuffer
+"/    self 
+"/        spawnMethodSendersBrowserFor:(Array with:mSelector) 
+"/        in:#newBuffer
 
     "Modified: / 18.8.2000 / 19:50:45 / cg"
 !
@@ -30755,9 +30784,9 @@
     "double click on a protocol:
         open a full-protocol browser"
 
-    self theSingleSelectedProtocol notNil ifTrue:[
-        self protocolMenuSpawnFullCategoryBuffer
-    ]
+"/    self theSingleSelectedProtocol notNil ifTrue:[
+"/        self protocolMenuSpawnFullCategoryBuffer
+"/    ]
 !
 
 variableDoubleClicked
@@ -50635,6 +50664,6 @@
 !NewSystemBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Attic/NewSystemBrowser.st,v 1.227 2001-10-17 13:47:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Attic/NewSystemBrowser.st,v 1.228 2001-10-18 09:22:39 tm Exp $'
 ! !
 NewSystemBrowser initialize!
--- a/Tools__NewSystemBrowser.st	Wed Oct 17 15:47:06 2001 +0200
+++ b/Tools__NewSystemBrowser.st	Thu Oct 18 11:22:39 2001 +0200
@@ -20966,7 +20966,14 @@
     className isNil ifTrue:[^ self "cancel"].
 
     singleClass ifTrue:[
-        className := self askForClassNameMatching:className.
+        className includesMatchCharacters ifFalse:[
+            class := Smalltalk at:className asSymbol.
+            class isNil ifTrue:[
+                ^ self warn:'No such class'.
+            ].
+        ] ifTrue:[
+            className := self askForClassNameMatching:className.
+        ].
         className notNil ifTrue:[
             doWhat == #newBrowser ifTrue:[
                 brwsr := self class new.
@@ -20994,7 +21001,7 @@
             classes := classes asOrderedCollection.
         ].
         classes size == 0 ifTrue:[
-            ^ self warn:'no className matches'.
+            ^ self warn:'No className matches'.
         ].
         doWhat isNil ifTrue:[
             "/ select them ...
@@ -24894,18 +24901,27 @@
      substringMatchingNames caselessSubstringMatchingNames
      caselessWithoutPrefixSubstringMatchingNames
      lcMatchString subMatch lcSubMatch box className
-     needSearch cls env pref aMatchString allNames sortedBySpellingDistance|
+     needSearch cls env searchBlock
+     idx pref aMatchString allNames sortedBySpellingDistance|
 
     env := self navigationState environment.
 
     aMatchString := matchStringArg.
 
+    "/ try to limit search to a namespace (but only if nameSpace is not a matchCharacter)
+
     (aMatchString includesString:'::') ifTrue:[
-        pref := aMatchString upTo:$:.
-        cls := Smalltalk at:pref asSymbol ifAbsent:nil.
-        (cls notNil and:[cls isBehavior]) ifTrue:[
-            env := cls.
-            aMatchString := aMatchString copyFrom:pref size + 1 + 2.
+        "/ pref := aMatchString upTo:$:.       
+        idx := aMatchString lastIndexOf:$:.
+        pref := aMatchString copyTo:idx-2.
+        pref includesMatchCharacters ifTrue:[
+            "/ search all in Smalltalk
+        ] ifFalse:[
+            cls := Smalltalk at:pref asSymbol ifAbsent:nil.
+            (cls notNil and:[cls isBehavior]) ifTrue:[
+                env := cls.
+                aMatchString := aMatchString copyFrom:pref size + 1 + 2.
+            ].
         ].
     ].
 
@@ -24936,7 +24952,7 @@
     ].
 
     needSearch ifTrue:[
-        env allClassesDo:[:aClass |
+        searchBlock := [:aClass |
             |thisName|
 
             "/ to make it look better,
@@ -24948,10 +24964,14 @@
             ] ifFalse:[
                 thisName := aClass name
             ].
-
-            (lcMatchString match:aClass nameWithoutPrefix asLowercase) ifTrue:[
+            (lcMatchString match:aClass name asLowercase) ifTrue:[
                 caselessWithoutPrefixSubstringMatchingNames add:thisName
             ].
+            aClass nameWithoutPrefix ~= aClass name ifTrue:[
+                (lcMatchString match:aClass nameWithoutPrefix asLowercase) ifTrue:[
+                    caselessWithoutPrefixSubstringMatchingNames add:thisName
+                ].
+            ].
 
             (aMatchString match:thisName) ifTrue:[
                 classNames add:thisName
@@ -24972,6 +24992,12 @@
             ]
         ].
 
+        (env == Smalltalk or:[env isNamespace]) ifTrue:[
+            env allClassesDo:searchBlock
+        ] ifFalse:[
+            env allPrivateClasses do:searchBlock
+        ].
+
         sortedBySpellingDistance := false.
 
         "/ if nothing matched - try caseless matches
@@ -25028,6 +25054,9 @@
             ].
             box action:[:aString | className := aString].
             box open.
+            className isNil ifTrue:[ "/ cancel
+                ^ nil
+            ]
         ].
     ].
 
@@ -25038,9 +25067,9 @@
         ].
     ].
 
-    pref notNil ifTrue:[
-        ^ pref , '::' , className
-    ].
+"/    pref notNil ifTrue:[
+"/        ^ pref , '::' , className
+"/    ].
     ^ className
 
     "Modified: / 13.2.2000 / 20:57:42 / cg"
@@ -30568,7 +30597,7 @@
 !
 
 methodDoubleClicked:aMethod
-    |resources editorClass "brwsr" mSelector mClass|
+    |resources editorClass brwsr mSelector mClass|
 
     mSelector := aMethod selector.
     mClass := aMethod mclass.
@@ -30628,9 +30657,9 @@
     "/
     "/ double clicking on any other method adds a senders buffer
     "/
-    self 
-        spawnMethodSendersBrowserFor:(Array with:mSelector) 
-        in:#newBuffer
+"/    self 
+"/        spawnMethodSendersBrowserFor:(Array with:mSelector) 
+"/        in:#newBuffer
 
     "Modified: / 18.8.2000 / 19:50:45 / cg"
 !
@@ -30755,9 +30784,9 @@
     "double click on a protocol:
         open a full-protocol browser"
 
-    self theSingleSelectedProtocol notNil ifTrue:[
-        self protocolMenuSpawnFullCategoryBuffer
-    ]
+"/    self theSingleSelectedProtocol notNil ifTrue:[
+"/        self protocolMenuSpawnFullCategoryBuffer
+"/    ]
 !
 
 variableDoubleClicked
@@ -50635,6 +50664,6 @@
 !NewSystemBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.227 2001-10-17 13:47:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__NewSystemBrowser.st,v 1.228 2001-10-18 09:22:39 tm Exp $'
 ! !
 NewSystemBrowser initialize!