Marcus has shown me previously ast with nodesDo: for example this code show me the full ast for my class method blenderOpen of my class Ephestos.

(Ephestos class compiledMethodAt: ��#blenderOpen ) ast nodesDo: [ :node| ��node inspect]

and it opens one inspector per node

messages that are "method calls" are nodes of RBMessageNode class. I see a instance variable "selector" which returns the name of the selector and an instance variable "receiver" returns the name of the receiver. Instance variable "parent" describes the container of the message . For example in my case the only RBMessageNode is contained inside a variable assignment. ����

So I think its a good start for finding "method calls" messages.��


On Thu, Aug 7, 2014 at 11:18 AM, Cl��ment Bera <bera.clement@gmail.com> wrote:



2014-08-07 5:11 GMT+02:00 aria2end <aria2end@gmail.com>:

Hi, I know that I can see senders and implementers of a method but is there
any way to see all methods that are used in a method ?

This is impossible. The method called for each message send can only been known at runtime, because it depends on the receiver class. The only thing you could see is the list of selectors (name of methods) called from this method. This is possible by sending #messages to the compiledMethod.

Example:

you have a method named #foo:bar: implemented in MyClass:
MyClass>>foo: arg1 bar: arg2
�� �� ^ self baz: arg1 + arg2

You can open a workspace, and run:
(MyClass��>>#foo:bar:) messages

which answers:
a Set(#baz: #+)

but you cannot see the methods called, because depending on the class of arg1, the method called for #+ may be any of these methods:
AJMem>>#+ Collection>>#+ Color>>#+ DateAndTime>>#+ Duration>>#+ Float>>#+ FloatArray>>#+ Fraction>>#+ Integer>>#+ Interval>>#+ KMComposedModifier>>#+ KMKeyCombinationSequence>>#+ KMModifier>>#+ KMNoShortcut>>#+ LargeInteger>>#+ Number>>#+ Point>>#+ ROAbstractComponent>>#+ ROShape>>#+ ROShape class>>#+ ScaledDecimal>>#+ SmallInteger>>#+ String>>#+ Timespan>>#+ TraitComposition>>#+ TraitDescription>>#+ TraitTransformation>>#+ WordArray>>#+ TComposingDescription>>#+

Or perhaps you want to see all the potential methods called. Then you can open a workspace and run this script:

| methods mb |
methods := ((CompiledMethod>>#foo:bar:) messages collect: [ :selector | selector implementors ]) flattened.
mb := MethodBrowser new.
mb openWithSpec.
mb methods: methods

��
��or any way to see
all the send messages to other methods limited to scope of a method ?

all the send messages to other methods ?

Well for that you'll need type inference to find out which variables are actually methods, and then see what messages are sent to those variables. But why would one want to do that ?

Thanks,
Aria





--
View this message in context: http://forum.world.st/Seeing-all-the-methods-that-is-used-in-a-method-tp4772100.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.