如何使用Eclipse JDT对JDK中的所有方法调用进行计数 [英] How to count all the method calls in JDK using Eclipse JDT

查看:391
本文介绍了如何使用Eclipse JDT对JDK中的所有方法调用进行计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须对JDK中的所有方法进行计数,对于每个类,对其接收到的方法调用进行计数;
为每个方法,计算此方法的调用次数;



提示:使用Eclipse JDT创建抽象语法树。



任何身体都可以解释我应该如何解决这个问题。一个简单的算法将是很大的帮助。
谢谢

解决方案

您可以使用以下步骤解决您的问题:


  1. 首先将您的java类转换为 CompilationUnit ,以便可以
    遍历。

  2. 然后使用 ASTVisitor 模式访问
    MethodDeclaration 节点(方法调用)

  3. 使用JDT SearchEngine
    MethodDeclaration 进行引用搜索功能

参考以下帖子:




I have to count all the methods in JDK, for each class, count the method calls it received; for each method, count the number of times this method is called;

Hint: Use Eclipse JDT to create Abstract Syntax tree.

Can any body please explain how should I approach this problem. A brief algorithm would be great help. Thanks

解决方案

You can approach your problem using the below steps:

  1. First convert your java class to a CompilationUnit so that it can be traversed.
  2. Then use the ASTVisitor pattern to visit the MethodDeclaration node (method call)
  3. Do a reference search for the MethodDeclaration using JDT SearchEngine capabilities

Refer the below posts:

这篇关于如何使用Eclipse JDT对JDK中的所有方法调用进行计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆