如何使用JDT获取封闭方法节点? [英] How to get the enclosing method node with JDT?
本文介绍了如何使用JDT获取封闭方法节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void foo()
{
b.bar();
}
解决方案
在JDT /一个帮忙的方法来做到这一点。看看 org.eclipse.jdt.internal.corext.dom.ASTNodes.getParent(ASTNode,int)
When I have a method foo() that calls bar(), how can I get the foo() AST node from MethodInvocation node (or whatever statements/expressions in the method)? For example, I need to know the IMethod foo from b.bar().
public void foo()
{
b.bar();
}
解决方案
In JDT/UI we have a helper method to do this. Take a look at org.eclipse.jdt.internal.corext.dom.ASTNodes.getParent(ASTNode, int)
这篇关于如何使用JDT获取封闭方法节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文