DoWhatIMeanSupport.st
changeset 3841 1f681141ba33
parent 3761 6584390d427d
child 3852 53a677825c05
--- a/DoWhatIMeanSupport.st	Mon Nov 02 16:17:35 2009 +0100
+++ b/DoWhatIMeanSupport.st	Mon Nov 02 17:51:57 2009 +0100
@@ -238,7 +238,7 @@
      bestSelectors selector2 bestSelectors2 allBest best info numArgs
      newParts nSelParts oldLen newLen selectorParts 
      findBest parentNode selectorInBest selector2InBest2
-     parser selectorsSentInCode allBest1 allBest2|
+     parser selectorsSentInCode split|
 
     parser := Parser parseMethod:codeView contents string in:cls ignoreErrors:true ignoreWarnings:true.
     selectorsSentInCode := parser messagesSent.
@@ -306,18 +306,28 @@
 
     allBest isEmptyOrNil ifTrue:[ ^ self ].
 
+    split := [:list :splitHow |
+        |part1 part2 all|
+
+        part1 := list select:splitHow.
+        part2 := list reject:splitHow.
+        part1 isEmpty ifTrue:[
+            all := part2.
+        ] ifFalse:[
+            part2 isEmpty ifTrue:[
+                all := part1.
+            ] ifFalse:[
+                all := part1 , part2.
+            ]
+        ].
+        all
+    ].
+
     "/ the ones already sent in the code are moved to the top of the list.
-    allBest1 := allBest select:[:sel | selectorsSentInCode includes:sel].
-    allBest2 := allBest reject:[:sel | selectorsSentInCode includes:sel].
-    allBest1 isEmpty ifTrue:[
-        allBest := allBest2.
-    ] ifFalse:[
-        allBest2 isEmpty ifTrue:[
-            allBest := allBest1.
-        ] ifFalse:[
-            allBest := allBest1 , #(nil), allBest2.
-        ]
-    ].
+    allBest := split value:allBest value:[:sel | selectorsSentInCode includes:sel].
+
+    "/ the ones which are a prefix are moved towards the top of the list
+    allBest := split value:allBest value:[:sel | sel startsWith:selector].
 
     best := allBest first.
     allBest size > 1 ifTrue:[
@@ -1820,9 +1830,9 @@
 !DoWhatIMeanSupport class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.60 2009-10-06 18:13:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.61 2009-11-02 16:51:57 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.60 2009-10-06 18:13:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/DoWhatIMeanSupport.st,v 1.61 2009-11-02 16:51:57 cg Exp $'
 ! !