从 ITypeBinding 获取合成方法
我正在使用在 ASTParserASTNode
上调用 resolveBinding()
时获得的 ITypeBinding
。 code> 和来自 Java 项目的 K_COMPILATION_UNIT。
例如,我已经解析了 java.lang.String
的 ITypeBinding,但缺少合成方法(在本例中为 compareTo(Object)
)。 ITypeBinding 的文档指出合成方法可能存在,也可能不存在,但 isSynthetic 方法表明应该有某种方法来说服 ITypeBinding 也包含合成方法。
如果我通过调用 ITypeBinding.getJavaElement()
获得 IType
,它包含我正在寻找的合成方法,但如果我可以从 ITypeBinding 获取它们会更容易直接地。
有什么想法吗?
I'm playing with the ITypeBinding
that I get when calling resolveBinding()
on an ASTNode
in the AST made by ASTParser
and a K_COMPILATION_UNIT from a Java Project.
For example I have resolved an ITypeBinding for java.lang.String
, but the synthetic methods are missing (compareTo(Object)
in this case). The documentation for ITypeBinding states that the synthetic methods may or may not be there, but the isSynthetic method suggests there should be some way of convincing the ITypeBinding to include synthetic methods as well.
If I get an IType
by calling ITypeBinding.getJavaElement()
it contains the synthetic methods I'm looking for, but it would be easier if I could get them from the ITypeBinding directly.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过查看显式跳过合成方法的实现找到了答案 - 首先在从编译器 AST 恢复方法时跳过它们,然后始终从 isSynthetic 方法的实现中返回 false - Eclipse 3.7 就是这样。
I found my answer by looking at the implementation which explicitly skips synthetic methods - first by skipping them when recovering methods from the compiler AST and then by always returning false from the implementation of isSynthetic method - this is so for Eclipse 3.7.