added: #selectorCompletion:inEnvironment:match:ignoreCase:
authorClaus Gittinger <cg@exept.de>
Tue, 26 Oct 2010 20:34:15 +0200
changeset 3955 94fb4a47d108
parent 3954 e28b5c4fe0c9
child 3956 32c277e2d606
added: #selectorCompletion:inEnvironment:match:ignoreCase: changed: #selectorCompletion:inEnvironment:match:
DoWhatIMeanSupport.st
--- a/DoWhatIMeanSupport.st	Tue Oct 26 12:47:16 2010 +0200
+++ b/DoWhatIMeanSupport.st	Tue Oct 26 20:34:15 2010 +0200
@@ -1568,6 +1568,29 @@
      2 entries: 1st: the longest match
                 2nd: collection consisting of matching implemented selectors"
 
+    ^ self 
+        selectorCompletion:aPartialSymbolName 
+        inEnvironment:anEnvironment 
+        match:doMatch 
+        ignoreCase:false
+
+    "
+     DoWhatIMeanSupport selectorCompletion:'inst*p' inEnvironment:Smalltalk match:true 
+     DoWhatIMeanSupport selectorCompletion:'inst*pl' inEnvironment:Smalltalk match:true 
+     DoWhatIMeanSupport selectorCompletion:'at:p' inEnvironment:Smalltalk match:true 
+     DoWhatIMeanSupport selectorCompletion:'nextP' inEnvironment:Smalltalk match:true
+     DoWhatIMeanSupport selectorCompletion:'nextp' inEnvironment:Smalltalk match:true
+    "
+
+    "Modified: / 07-06-1996 / 08:44:33 / stefan"
+    "Modified: / 26-10-2010 / 20:30:27 / cg"
+!
+
+selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:doMatch ignoreCase:ignoreCase
+    "given a partial selector, return an array consisting of
+     2 entries: 1st: the longest match
+                2nd: collection consisting of matching implemented selectors"
+
     |matches best lcSym isMatch|
 
     matches := IdentitySet new.
@@ -1576,13 +1599,15 @@
 
     anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector |
         (isMatch 
-            ifTrue:[ (aPartialSymbolName match:eachSelector) ]
-            ifFalse:[ (eachSelector startsWith:aPartialSymbolName) ])
+            ifTrue:[ (aPartialSymbolName match:eachSelector ignoreCase:ignoreCase) ]
+            ifFalse:[ ignoreCase 
+                        ifTrue:[ (eachSelector asLowercase startsWith:aPartialSymbolName asLowercase) ]  
+                        ifFalse:[ (eachSelector startsWith:aPartialSymbolName) ] ])
          ifTrue:[
             matches add:eachSelector
         ].
     ].
-    matches isEmpty ifTrue:[
+    (matches isEmpty and:[ignoreCase not]) ifTrue:[
         "/ search for case-ignoring match
         lcSym := aPartialSymbolName asLowercase.
         anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector |
@@ -1613,8 +1638,8 @@
      DoWhatIMeanSupport selectorCompletion:'nextp' inEnvironment:Smalltalk match:true
     "
 
-    "Modified: / 7.6.1996 / 08:44:33 / stefan"
-    "Modified: / 14.6.1998 / 15:54:03 / cg"
+    "Modified: / 07-06-1996 / 08:44:33 / stefan"
+    "Created: / 26-10-2010 / 20:30:06 / cg"
 ! !
 
 !DoWhatIMeanSupport class methodsFor:'rename support'!
@@ -1931,9 +1956,9 @@
 !DoWhatIMeanSupport class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.74 2010-08-24 13:28:35 sr Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.75 2010-10-26 18:34:15 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.74 2010-08-24 13:28:35 sr Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.75 2010-10-26 18:34:15 cg Exp $'
 ! !