Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for .prototype method calls? #13

Closed
jakedowns opened this issue Oct 19, 2016 · 2 comments
Closed

Support for .prototype method calls? #13

jakedowns opened this issue Oct 19, 2016 · 2 comments
Labels

Comments

@jakedowns
Copy link

First off, this is a great start! and a tool I've been searching for for a long time.

It appears that .prototype method calls on custom class/functions aren't graphed?

Is this something you plan on adding? Or am I missing something obvious?

Thanks again for sharing such a cool package. I might try to dig into the source code a bit if I can find the time.

@jakedowns
Copy link
Author

jakedowns commented Oct 19, 2016

Ah, just took a look at the parser. Very smart re-using Uglify's walker.

I see the filterTuple which prevents lib calls which is good, otherwise the graph would be polluted with calls. I disabled the filter to see what would happen, and now I see that prototype calls end up being very flat/wide cause the tree walker doesn't seem to have an awareness of "this." instance calls referencing a particular class.

Any thoughts on how you'd approach enabling graphing something like that?

Here's what I'm aiming for:
diagram 2

digraph G {
    subgraph cluster_0 {
        label = "Class A";

        a -> b;
        a -> c -> e -> f;
        a -> d;
     }

    subgraph cluster_1 {
        label = "Class B";
         g -> h;
         i;
    }

    f -> g [constraint=false];
    d -> i [constraint=false];
}

@gunar
Copy link
Owner

gunar commented Oct 20, 2016

Thanks, @jakedowns. It is my understanding that the problem you presented is the reason why there were no such tools for JS since callgraph. The dynamic/prototypal nature of JS makes it very hard to correctly understand such calls from the static code only (from the AST). In order to do that, one would have to actually interpret (run) the code.

I'm afraid this tool won't ever be 100% "compliant". However, there are still use cases for it.

@gunar gunar added the wontfix label Oct 20, 2016
@gunar gunar closed this as completed Oct 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants