call-graph icon indicating copy to clipboard operation
call-graph copied to clipboard

Add support for implicit usage

Open AHJiapengZhang opened this issue 1 year ago • 3 comments

In python for example, a function may be called implicitly by functools.reduce and functools.partial etc. On the surface it looks it's another function that is running, but under the hood it's still the function of our interest that is running. But couldn't the plugin is not able to detect such usage.

Example:

from functools import partial

def function(a, b, c):
    print(a, b, c)
    
    
f = partial(function, 1, 2)
f(3)
image Here the function f should be captured in the graph. Because it's this `f` that is invoking the underlying `function` we have defined.

AHJiapengZhang avatar Sep 24 '24 09:09 AHJiapengZhang

@AHJiapengZhang This extension relies on the CallHierarchyIncomingCall and CallHierarchyOutgoingCall APIs. If implicit calls are not supported, then it's not going to show up in the graph.

I reproduced your experiment and when I right click the function and select "show call hierarchy" in the context menu nothing shows up meaning that vscode is not able to detect it therefore the extension is also not able to detect it.

I don't know what is @beicause's opinion on it, but it sounds like a "won't fix" because stepping out of the vscode api would imply in a major refactor.

jotavemonte avatar Nov 18 '24 14:11 jotavemonte

@jotavemonte Thanks for updating. I will also try to reach out to VSCode team about this issue.

AHJiapengZhang avatar Nov 18 '24 15:11 AHJiapengZhang

@jotavemonte Thanks for updating. I will also try to reach out to VSCode team about this issue.

Same issue in Golang ".func()"

I have try to fix it in https://github.com/beicause/call-graph/pull/21

But not merged. it's the beast way to reach out to VSCode team.

shenguanjiejie avatar Dec 05 '24 06:12 shenguanjiejie