# HG changeset patch
# User Jan Vrany <jan.vrany@fit.cvut.cz>
# Date 1538126280 -3600
# Fri Sep 28 10:18:00 2018 +0100
# Branch jv
# Node ID 73c795373547fe280e89c59316e5acc1aa6bcf44
# Parent a1d5f7f3d8458411926b95857aa2fb3378afa4e1
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
diff -r a1d5f7f3d845 -r 73c795373547 Tools__MethodList.st
a
|
b
|
|
416 | 416 | however, ensure that the refs to the old method are updated |
417 | 417 | " |
418 | 418 | methods := selection. |
419 | | selection notEmpty ifTrue:[ |
| 419 | selection notEmptyOrNil ifTrue:[ |
420 | 420 | (methods includesIdentical:oldMethod) ifTrue:[ |
421 | 421 | needSelectionChange := true. |
422 | 422 | ] |
… |
… |
|
425 | 425 | lastSelectedMethods notNil ifTrue:[ |
426 | 426 | lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod |
427 | 427 | ]. |
428 | | selection notEmpty ifTrue:[ |
| 428 | selection notEmptyOrNil ifTrue:[ |
429 | 429 | methods := methods asOrderedCollection. |
430 | 430 | methods replaceAllIdentical:oldMethod with:newMethod. |
431 | 431 | ]. |
… |
… |
|
503 | 503 | "/ We have to handle the case the method was wrapped before |
504 | 504 | "/ and now is wrapped differently - for example there was be breakpoint |
505 | 505 | "/ changed to trace point. |
506 | | "/ |
| 506 | "/ |
507 | 507 | "/ In that case, the oldMethod (the one that is in the selection and the one |
508 | 508 | "/ that WAS installed in the class is not `newMethod originalMethod` but it's the |
509 | | "/ method whose originalMethod is the same as `newMethod originalMethod`. |
510 | | "/ |
| 509 | "/ method whose originalMethod is the same as `newMethod originalMethod`. |
| 510 | "/ |
511 | 511 | "/ Since we're interested in this case if such method is selected, checn the selection. |
512 | 512 | "/ A little tricky, we'll see. |
513 | | "/ |
| 513 | "/ |
514 | 514 | "/ See https://swing.fit.cvut.cz/projects/ticket/103 |
515 | | "/ |
516 | | selection notEmpty ifTrue:[ |
| 515 | "/ |
| 516 | selection notEmptyOrNil ifTrue:[ |
517 | 517 | oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == oldMethod"newMethod originalMethod"]] ifNone:oldMethod. |
518 | 518 | ] |
519 | 519 | ] ifFalse:[ |
520 | | selection notEmpty ifTrue:[ |
| 520 | selection notEmptyOrNil ifTrue:[ |
521 | 521 | oldMethod := selection detect:[:each | each isWrapped and:[each originalMethod == newMethod]] ifNone:nil. |
522 | 522 | ] |
523 | 523 | ]. |
524 | 524 | |
525 | | selection notEmpty ifTrue:[ |
| 525 | selection notEmptyOrNil ifTrue:[ |
526 | 526 | (selection includesIdentical:oldMethod) ifTrue:[ |
527 | 527 | needSelectionChange := true. |
528 | 528 | ] |
… |
… |
|
531 | 531 | lastSelectedMethods notNil ifTrue:[ |
532 | 532 | lastSelectedMethods replaceAllIdentical:oldMethod with:newMethod |
533 | 533 | ]. |
534 | | selection notEmpty ifTrue:[ |
| 534 | selection notEmptyOrNil ifTrue:[ |
535 | 535 | "/ Used to be: |
536 | | "/ |
| 536 | "/ |
537 | 537 | "/ selection := selection asOrderedCollection, |
538 | 538 | "/ selection replaceAllIdentical:oldMethod with:newMethod. |
539 | | "/ |
| 539 | "/ |
540 | 540 | "/ but that's WRONG!! If the selection is not an ordered collection, |
541 | 541 | "/ then asOrderedCollection would create new collection noone else |
542 | | "/ references and thus the replace is useless. If the selection |
| 542 | "/ references and thus the replace is useless. If the selection |
543 | 543 | "/ is already an OrderedCollection, then #asOrderedCollection is |
544 | 544 | "/ itself useless. |
545 | | "/ |
| 545 | "/ |
546 | 546 | "/ The former case (when selection was for example an array) caused |
547 | 547 | "/ selection loss on some cases, hard to chase down!! |
548 | | selection isSequenceable ifTrue:[ |
| 548 | selection isSequenceable ifTrue:[ |
549 | 549 | selection replaceAllIdentical:oldMethod with:newMethod. |
550 | | ] ifFalse:[ |
551 | | "/ Now, are we sure selection is always a sequenceable? |
| 550 | ] ifFalse:[ |
| 551 | "/ Now, are we sure selection is always a sequenceable? |
552 | 552 | "/ I (JV) am not sure so handle (Identity)Set cases too: |
553 | | self breakPoint: #jv. |
554 | | (selection includesIdentical: oldMethod) ifTrue:[ |
| 553 | self breakPoint: #jv. |
| 554 | (selection includesIdentical: oldMethod) ifTrue:[ |
555 | 555 | selection removeIdentical: oldMethod. |
556 | 556 | selection add: newMethod. |
557 | 557 | ]. |
… |
… |
|
748 | 748 | |
749 | 749 | "Created: / 05-02-2000 / 13:42:14 / cg" |
750 | 750 | "Modified: / 05-06-2012 / 23:47:15 / cg" |
751 | | "Modified: / 16-10-2017 / 00:05:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
| 751 | "Modified: / 28-09-2018 / 10:16:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
752 | 752 | ! |
753 | 753 | |
754 | 754 | selectedMethodsChanged |
… |
… |
|
785 | 785 | "/ for big collections, generate a reverse map |
786 | 786 | reverseMap := IdentityDictionary new. |
787 | 787 | methods keysAndValuesDo:[:idx :mthd | reverseMap at:mthd put:idx]. |
788 | | indices := selectedMethods |
| 788 | indices := selectedMethods |
789 | 789 | collect:[:eachSelectedMethod | |
790 | 790 | reverseMap at:eachSelectedMethod ifAbsent:0] |
791 | 791 | thenSelect:[:idx | idx ~~ 0] |
792 | 792 | ] |
793 | 793 | ] ifFalse:[ |
794 | | indices := (selectedMethods ? #()) |
| 794 | indices := (selectedMethods ? #()) |
795 | 795 | collect:[:eachSelectedMethod | |
796 | 796 | methods identityIndexOf:eachSelectedMethod] |
797 | 797 | thenSelect:[:idx | idx ~~ 0] |
… |
… |
|
1312 | 1312 | methods add:mthd. |
1313 | 1313 | methodNameList add:{ cls name . sel}. |
1314 | 1314 | ]. |
1315 | | |
| 1315 | |
1316 | 1316 | self makeIndependent. |
1317 | 1317 | classes := newClasses. |
1318 | 1318 | self makeDependent. |
… |
… |
|
1326 | 1326 | mclass := theMethod mclass. |
1327 | 1327 | ]. |
1328 | 1328 | ]. |
1329 | | self methodLabelHolder |
| 1329 | self methodLabelHolder |
1330 | 1330 | value:(mclass isNil |
1331 | 1331 | ifTrue:[ ('???' , ' ' , '???') ] |
1332 | 1332 | ifFalse:[ (mclass name ? '*unnamed*'), ' ' , (theMethod selector asString) ]) |
… |
… |
|
1693 | 1693 | ^ selector withColor:Color red. |
1694 | 1694 | ]. |
1695 | 1695 | |
1696 | | (showClassFirst and:[cls notNil]) ifTrue:[ |
| 1696 | (showClassFirst and:[cls notNil]) ifTrue:[ |
1697 | 1697 | s := aMethod printStringForBrowserWithSelector:selector allBold inClass:cls. |
1698 | 1698 | s := cls nameInBrowser , ' ' , s |
1699 | 1699 | ] ifFalse:[ |
… |
… |
|
1724 | 1724 | "/ |
1725 | 1725 | icn isNil ifTrue:[ |
1726 | 1726 | (aMethod notNil and:[aMethod isMethodWithBreakpoints]) ifTrue:[ |
1727 | | aMethod hasEnabledBreakpoints ifTrue:[ |
| 1727 | aMethod hasEnabledBreakpoints ifTrue:[ |
1728 | 1728 | icn := self lineBreakPointedIcon |
1729 | | ] ifFalse:[ |
1730 | | aMethod hasEnabledTracepoints ifTrue:[ |
| 1729 | ] ifFalse:[ |
| 1730 | aMethod hasEnabledTracepoints ifTrue:[ |
1731 | 1731 | icn := self lineTracePointedIcon |
1732 | | ] ifFalse:[ |
| 1732 | ] ifFalse:[ |
1733 | 1733 | icn := self disabledBreakpointIcon |
1734 | | ] |
| 1734 | ] |
1735 | 1735 | ]. |
1736 | 1736 | ]. |
1737 | 1737 | ]. |