检查MethodDeclaration是否类似于IMethod [英] Check if MethodDeclaration similar to an IMethod

查看:133
本文介绍了检查MethodDeclaration是否类似于IMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以比较MethodDeclaration对象和IMethod对象并检查它们是否相似?还是可以通过任何方法将MethodDeclaration对象转换为IMethod对象(IMethod提供了isSimilar函数)?

Is there any way by which i can compare a MethodDeclaration object and IMethod object and check whether they are similar? Or is there any way by whcih a MethodDeclaration object can be converted to an IMethod object (IMethod provides a isSimilar function)?

更新:我想知道是否可以将FieldDeclaration转换为IField。

Update : Similarily i would like to know if a FieldDeclaration can be converted to a IField.

推荐答案

MethodDeclaration是ASTNode,而IMethod是JavaElement 。检查这两个对象是否对应同一方法的确定方法是比较它们的Binding。

MethodDeclaration is an ASTNode, and IMethod is a JavaElement. The definitive way to check if these two objects correspond to the same method is to compare their Binding.

请参见 http://wiki.eclipse.org/JDT/FAQ#From_an_ASTNode_to_an_IBinding http://wiki.eclipse.org/JDT/FAQ#From_an_IJavaElement_to_an_IBinding 关于如何获取ASTNode和JavaElement的绑定。一旦有了Binding或Binding键,就可以进行比较。

See http://wiki.eclipse.org/JDT/FAQ#From_an_ASTNode_to_an_IBinding and http://wiki.eclipse.org/JDT/FAQ#From_an_IJavaElement_to_an_IBinding on how to get the Binding for an ASTNode and for a JavaElement. Once you have the Binding or the Binding key you can just compare that.

这篇关于检查MethodDeclaration是否类似于IMethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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