#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Sat, 07 May 2016 12:33:17 +0200
changeset 19739 5f6b9dbd32c6
parent 19738 8ac31aac9eb6
child 19740 749958a29e1d
#FEATURE by cg class: Method added: #sendsMessageForWhich:
Method.st
--- a/Method.st	Sat May 07 12:32:29 2016 +0200
+++ b/Method.st	Sat May 07 12:33:17 2016 +0200
@@ -3462,6 +3462,29 @@
     "Created: / 08-08-2011 / 18:53:24 / cg"
 !
 
+sendsMessageForWhich:aCheckBlock
+    "return true, if this method contains a message-send
+     for which aCheckBlock returns true, when given the selector."
+
+    self literalsDo:[:each |
+        each isSymbol ifTrue:[
+            "/ first check if the selector matches
+            (aCheckBlock value:each) ifTrue:[
+                "/ then, if this is really a message send
+                (self messagesSent includes:each) ifTrue:[^ true].
+            ]
+        ]
+    ].    
+    ^ false
+
+    "
+     (self compiledMethodAt:#sendsAnyForWhich:) 
+        sendsAnyForWhich:[:sel | sel startsWith:'message']
+     (self compiledMethodAt:#sendsAnyForWhich:) 
+        sendsAnyForWhich:[:sel | sel startsWith:'foo']
+    "
+!
+
 shadowedMethod
     "Return the shadowed method if this method is an extension (i.e. package ~= classes' package)
      AND it shadows (redefines) an existing method from the method's class.