Issue #246: in `Tools::MethodList` use `#notEmptyOrNil` instead of `#notEmpty` jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 28 Sep 2018 10:18:00 +0100
branchjv
changeset 18445 73c795373547
parent 18394 a1d5f7f3d845
child 18446 84498b441bc0
Issue #246: in `Tools::MethodList` use `#notEmptyOrNil` instead of `#notEmpty` ... since method list selection may be `nil`. This fixes issue #246. https://swing.fit.cvut.cz/projects/stx-jv/ticket/246
Tools__MethodList.st
--- a/Tools__MethodList.st	Thu Sep 20 21:56:57 2018 +0100
+++ b/Tools__MethodList.st	Fri Sep 28 10:18:00 2018 +0100
@@ -416,7 +416,7 @@
                          however, ensure that the refs to the old method are updated
                         "
                         methods := selection.
-                        selection notEmpty ifTrue:[
+                        selection notEmptyOrNil ifTrue:[
                             (methods includesIdentical:oldMethod) ifTrue:[
                                 needSelectionChange := true.
                             ]
@@ -425,7 +425,7 @@
                         lastSelectedMethods notNil ifTrue:[
                             lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
                         ].
-                        selection notEmpty ifTrue:[
+                        selection notEmptyOrNil ifTrue:[
                             methods := methods asOrderedCollection.
                             methods replaceAllIdentical:oldMethod with:newMethod.
                         ].
@@ -503,26 +503,26 @@
                         "/ We have to handle the case the method was wrapped before
                         "/ and now is wrapped differently - for example there was be breakpoint
                         "/ changed to trace point.
-                        "/ 
+                        "/
                         "/ In that case, the oldMethod (the one that is in the selection and the one
                         "/ that WAS installed in the class is not `newMethod originalMethod` but it's the
-                        "/ method whose originalMethod is the same as `newMethod originalMethod`. 
-                        "/ 
+                        "/ method whose originalMethod is the same as `newMethod originalMethod`.
+                        "/
                         "/ Since we're interested in this case if such method is selected, checn the selection.
                         "/ A little tricky, we'll see.
-                        "/ 
+                        "/
                         "/ See https://swing.fit.cvut.cz/projects/ticket/103
-                        "/ 
-                        selection notEmpty ifTrue:[
+                        "/
+                        selection notEmptyOrNil ifTrue:[
                             oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == oldMethod"newMethod originalMethod"]] ifNone:oldMethod.
                         ]
                     ] ifFalse:[
-                        selection notEmpty ifTrue:[
+                        selection notEmptyOrNil ifTrue:[
                             oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil.
                         ]
                     ].
 
-                    selection notEmpty ifTrue:[
+                    selection notEmptyOrNil ifTrue:[
                         (selection includesIdentical:oldMethod) ifTrue:[
                             needSelectionChange := true.
                         ]
@@ -531,27 +531,27 @@
                     lastSelectedMethods notNil ifTrue:[
                         lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod
                     ].
-                    selection notEmpty ifTrue:[
+                    selection notEmptyOrNil ifTrue:[
                         "/ Used to be:
-                        "/ 
+                        "/
                         "/     selection := selection asOrderedCollection,
                         "/     selection replaceAllIdentical:oldMethod with:newMethod.
-                        "/ 
+                        "/
                         "/ but that's WRONG!! If the selection is not an ordered collection,
                         "/ then asOrderedCollection would create new collection noone else
-                        "/ references and thus the replace is useless. If the selection 
+                        "/ references and thus the replace is useless. If the selection
                         "/ is already an OrderedCollection, then #asOrderedCollection is
                         "/ itself useless.
-                        "/ 
+                        "/
                         "/ The former case (when selection was for example an array) caused
                         "/ selection loss on some cases, hard to chase down!!
-                        selection isSequenceable ifTrue:[ 
+                        selection isSequenceable ifTrue:[
                             selection replaceAllIdentical:oldMethod with:newMethod.
-                        ] ifFalse:[ 
-                            "/ Now, are we sure selection is always a sequenceable? 
+                        ] ifFalse:[
+                            "/ Now, are we sure selection is always a sequenceable?
                             "/ I (JV) am not sure so handle (Identity)Set cases too:
-                            self breakPoint: #jv.  
-                            (selection includesIdentical: oldMethod) ifTrue:[ 
+                            self breakPoint: #jv.
+                            (selection includesIdentical: oldMethod) ifTrue:[
                                 selection removeIdentical: oldMethod.
                                 selection add: newMethod.
                             ].
@@ -748,7 +748,7 @@
 
     "Created: / 05-02-2000 / 13:42:14 / cg"
     "Modified: / 05-06-2012 / 23:47:15 / cg"
-    "Modified: / 16-10-2017 / 00:05:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-09-2018 / 10:16:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 selectedMethodsChanged
@@ -785,13 +785,13 @@
                 "/ for big collections, generate a reverse map
                 reverseMap := IdentityDictionary new.
                 methods keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx].
-                indices := selectedMethods 
+                indices := selectedMethods
                                 collect:[:eachSelectedMethod |
                                     reverseMap at:eachSelectedMethod ifAbsent:0]
                                 thenSelect:[:idx | idx ~~ 0]
             ]
         ] ifFalse:[
-            indices := (selectedMethods ? #()) 
+            indices := (selectedMethods ? #())
                             collect:[:eachSelectedMethod |
                                 methods identityIndexOf:eachSelectedMethod]
                             thenSelect:[:idx | idx ~~ 0]
@@ -1312,7 +1312,7 @@
         methods add:mthd.
         methodNameList add:{ cls name . sel}.
     ].
-    
+
     self makeIndependent.
     classes := newClasses.
     self makeDependent.
@@ -1326,7 +1326,7 @@
                 mclass := theMethod mclass.
             ].
         ].
-        self methodLabelHolder 
+        self methodLabelHolder
                 value:(mclass isNil
                     ifTrue:[ ('???' , ' ' , '???') ]
                     ifFalse:[ (mclass name ? '*unnamed*'), ' ' , (theMethod selector asString) ])
@@ -1693,7 +1693,7 @@
         ^ selector withColor:Color red.
     ].
 
-    (showClassFirst and:[cls notNil]) ifTrue:[        
+    (showClassFirst and:[cls notNil]) ifTrue:[
         s := aMethod printStringForBrowserWithSelector:selector allBold inClass:cls.
         s := cls nameInBrowser , ' ' , s
     ] ifFalse:[
@@ -1724,14 +1724,14 @@
     "/
     icn isNil ifTrue:[
         (aMethod notNil and:[aMethod isMethodWithBreakpoints]) ifTrue:[
-            aMethod hasEnabledBreakpoints ifTrue:[ 
+            aMethod hasEnabledBreakpoints ifTrue:[
                 icn := self lineBreakPointedIcon
-            ] ifFalse:[    
-                aMethod hasEnabledTracepoints ifTrue:[ 
+            ] ifFalse:[
+                aMethod hasEnabledTracepoints ifTrue:[
                     icn := self lineTracePointedIcon
-                ] ifFalse:[    
+                ] ifFalse:[
                     icn := self disabledBreakpointIcon
-                ]    
+                ]
             ].
         ].
     ].