I donβt know the exact AST, but you can certainly read byte codes using packages such as ASM or BCEL, and scanning these data structures for function calls would be quite simple. Of course, this can happen after some early optimization has been done, so it cannot directly reflect the source ... and it is before the JIT, therefore it cannot directly reflect what actually works.
Another solution would be to run code under the control of the profiler, which can give you either the relative or absolute frequency of the call from different places.
None of them would give you the amount of imports - this is a purely syntactically sugar detail. But for the same reason, I do not think this is a really significant number.
source share