# HG changeset patch # User Claus Gittinger # Date 1486896891 -3600 # Node ID 9c87da351c9c1361d832ded7d1b6ce742954bf88 # Parent 1009583a873cb2a462546e239351bf347c8f9c5d #DOCUMENTATION by cg class: Tools::ViewTreeInspectorApplication asking myself if that code knows what it does diff -r 1009583a873c -r 9c87da351c9c Tools__ViewTreeApplication.st --- a/Tools__ViewTreeApplication.st Wed Feb 08 01:02:22 2017 +0100 +++ b/Tools__ViewTreeApplication.st Sun Feb 12 11:54:51 2017 +0100 @@ -4071,42 +4071,52 @@ do:aOneArgBlock "evaluate the argument, aBlock for each item in the selection " - |cashedSelection| - - cashedSelection := selection. - cashedSelection isNil ifTrue:[^ nil]. - ^ cashedSelection do:aOneArgBlock + |keptSelection| + + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[^ nil]. + ^ keptSelection do:aOneArgBlock + + "Modified (format): / 12-02-2017 / 11:53:23 / cg" ! from:start do:aOneArgBlock "evaluate the argument, aBlock for the items starting at index start " - |cashedSelection| - - cashedSelection := selection. - cashedSelection isNil ifTrue:[^ nil]. - ^ cashedSelection from:start do:aOneArgBlock + |keptSelection| + + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[^ nil]. + "/ but if so, then start may no longer be valid here?? + ^ keptSelection from:start do:aOneArgBlock + + "Modified (comment): / 12-02-2017 / 11:52:57 / cg" ! from:start to:stop do:aOneArgBlock "evaluate the argument, aBlock for the items with index start to stop in the selection. " - |cashedSelection| - - cashedSelection := selection. - cashedSelection isNil ifTrue:[^ nil]. - ^ cashedSelection from:start to:stop do:aOneArgBlock + |keptSelection| + + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[^ nil]. + "/ but if so, then start and stop may no longer be valid here?? + ^ keptSelection from:start to:stop do:aOneArgBlock + + "Modified (comment): / 12-02-2017 / 11:52:25 / cg" ! reverseDo:aOneArgBlock "evaluate the argument, aBlock for each item in the selection " - |cashedSelection| - - cashedSelection := selection. - cashedSelection isNil ifTrue:[^ nil]. - ^ cashedSelection reverseDo:aOneArgBlock + |keptSelection| + + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[^ nil]. + ^ keptSelection reverseDo:aOneArgBlock + + "Modified: / 12-02-2017 / 11:50:02 / cg" ! select:aBlock @@ -4259,11 +4269,13 @@ If none of the evaluations returns true, the result of the evaluation of the exceptionBlock is returned " - |cashedSelection| - - cashedSelection := selection. - cashedSelection isNil ifTrue:[ ^ exceptionBlock value ]. - ^ cashedSelection detect:aBlock ifNone:exceptionBlock + |keptSelection| + + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[ ^ exceptionBlock value ]. + ^ keptSelection detect:aBlock ifNone:exceptionBlock + + "Modified (format): / 12-02-2017 / 11:54:13 / cg" ! detectLast:aBlock @@ -4282,11 +4294,13 @@ If none of the evaluations returns true, the result of the evaluation of the exceptionBlock is returned " - |cashedSelection| - - cashedSelection := selection. - cashedSelection isNil ifTrue:[ ^ exceptionBlock value ]. - ^ cashedSelection detectLast:aBlock ifNone:exceptionBlock + |keptSelection| + + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[ ^ exceptionBlock value ]. + ^ keptSelection detectLast:aBlock ifNone:exceptionBlock + + "Modified (format): / 12-02-2017 / 11:53:49 / cg" ! ! !ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection testing'! @@ -4294,44 +4308,45 @@ includes:anItem "returns true if the item is in the current selection " - |cashedSelection| - - cashedSelection := selection. - cashedSelection isNil ifTrue:[^ false]. - ^ cashedSelection includesIdentical:anItem + |keptSelection| + + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[^ false]. + ^ keptSelection includesIdentical:anItem + + "Modified: / 12-02-2017 / 11:51:34 / cg" ! includesAll:aCollection "return true, if all items of the collection are included in the current selection " - |cashedSelection| + |keptSelection| aCollection size ~~ 0 ifTrue:[ - cashedSelection := selection. - cashedSelection isNil ifTrue:[ ^ false ]. - - aCollection do:[:el| - (cashedSelection includesIdentical:el) ifFalse:[^ false] - ] + "/ the selection may change at any time (may it?) + (keptSelection := selection) isNil ifTrue:[ ^ false ]. + + ^ aCollection contains:[:el| (keptSelection includesIdentical:el)] ]. ^ true + + "Modified (format): / 12-02-2017 / 11:51:14 / cg" ! includesAny:aCollection - "return true, if the any item of the collection is in the current selection + "return true, if any item of the collection is in the current selection " - |cashedSelection| + |keptSelection| aCollection notNil ifTrue:[ - cashedSelection := selection. - - cashedSelection notNil ifTrue:[ - aCollection do:[:el| - (cashedSelection includesIdentical:el) ifTrue:[^ true] - ] + "/ the selection may change at any time (may it?) + (keptSelection := selection) notNil ifTrue:[ + ^ aCollection contains:[:el| (keptSelection includesIdentical:el)] ] ]. ^ false + + "Modified (format): / 12-02-2017 / 11:50:26 / cg" ! includesIdentical:anItem