--- a/Context.st Fri Dec 16 14:24:54 2016 +0100
+++ b/Context.st Fri Dec 16 23:18:11 2016 +0100
@@ -933,12 +933,34 @@
withAllSendersDo:aBlock
"evaluate aBlock for me and all contexts of my sender chain"
+ self withSendersUpToContextForWhich:[:con | false] do:aBlock
+!
+
+withSendersThroughContextForWhich:checkBlock do:aBlock
+ "evaluate aBlock for me and all contexts of my sender chain,
+ until checkBlock returns true (incl. that last one)"
+
|con|
con := self.
[ con notNil ] whileTrue:[
- aBlock value:con.
- con := con sender.
+ aBlock value:con.
+ (checkBlock value:con) ifTrue:[^ self].
+ con := con sender.
+ ]
+!
+
+withSendersUpToContextForWhich:checkBlock do:aBlock
+ "evaluate aBlock for me and all contexts of my sender chain,
+ until checkBlock returns true, excl. that context."
+
+ |con|
+
+ con := self.
+ [ con notNil ] whileTrue:[
+ (checkBlock value:con) ifTrue:[^ self].
+ aBlock value:con.
+ con := con sender.
]
! !
@@ -1777,9 +1799,8 @@
fullPrintAllOn:aStream throughContextForWhich:aBlock
"print a full walkback (incl arguments) starting at the receiver"
- self withAllSendersDo:[:con |
+ self withSendersThroughContextForWhich:aBlock do:[:con |
con fullPrintOn:aStream. aStream cr.
- (aBlock value:con) ifTrue:[^ self].
].
"
@@ -1790,8 +1811,7 @@
fullPrintAllOn:aStream upToContextForWhich:aBlock
"print a full walkback (incl arguments) starting at the receiver"
- self withAllSendersDo:[:con |
- (aBlock value:con) ifTrue:[^ self].
+ self withSendersUpToContextForWhich:aBlock do:[:con |
con fullPrintOn:aStream. aStream cr.
].
@@ -1803,7 +1823,11 @@
fullPrintAllString
"return a string containing the full walkback (incl. arguments)"
- ^ String streamContents:[:s | self fullPrintAllOn:s]
+ |s|
+
+ s := WriteStream on:''.
+ self fullPrintAllOn:s.
+ ^ s contents
"
thisContext fullPrintAllString
@@ -1885,6 +1909,30 @@
"Created: 15.1.1997 / 18:09:05 / cg"
!
+printAllOn:aStream throughContextForWhich:aBlock
+ "print a short walkback (excl. arguments) starting at the receiver"
+
+ self withSendersThroughContextForWhich:aBlock do:[:con |
+ con printOn:aStream. aStream cr.
+ ].
+
+ "
+ thisContext printAllOn:Transcript throughContextForWhich:[:con | con selector == #doIt].
+ "
+!
+
+printAllOn:aStream upToContextForWhich:aBlock
+ "print a short walkback (excl. arguments) starting at the receiver"
+
+ self withSendersUpToContextForWhich:aBlock do:[:con |
+ con printOn:aStream. aStream cr.
+ ].
+
+ "
+ thisContext printAllOn:Transcript upToContextForWhich:[:con | con selector == #withCursor:do:].
+ "
+!
+
printAllString
"return a string containing the walkback (excl. arguments)"