- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 Eclipse 插件中,假设我持有 Java 类的 IJavaElement(也是 IType)
org.eclipse.jdt.core.IType
如何获取其父类(super class)的 IType(或其他一些对象表示形式,如 IJavaElement)?我不想使用 newSupertypeHierarchy() 因为这太大了。我只想要直接的、上一级的、父类(super class)的...
我尝试了以下所有方法
(在下面的代码中,“subType”是我想要获取其父类(super class)的类的 IJavaElement 表示形式):
System.out.println("subType root: "+((IType) subType).getTypeRoot().getElementName());
System.out.println("subType primary: "+subType.getPrimaryElement().getElementName());
System.out.println("subType ansc: "+((IType) subType).getAncestor(0));
System.out.println("subType dclr:"+((IType) subType).getDeclaringType());
System.out.println("subType parnt: "+((IType) subType).getParent().getElementName());
他们都没有产生父类(super class)
最佳答案
有IType.getSuperclassName(),但这只会给你父类(super class)的SimpleName。问题是,父类(super class)可能不在同一个项目中,甚至可能不在某个库 jar 中。这就是为什么需要更多资源来计算。
据我所知,这是获取父类(super class)的 IType 的最佳方法:
public static IType getSupertypeOf(final IType type, IProgressMonitor monitor) throws CoreException {
return type.newSupertypeHierarchy(monitor).getSuperclass(type);
}
关于java - (类的)IJavaElement/IType 出现问题 - 如何获取父类(super class)的 IType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9247101/
在 Eclipse 插件中,假设我持有 Java 类的 IJavaElement(也是 IType) org.eclipse.jdt.core.IType 如何获取其父类(super class)的
我目前正在研究基于 JDT 的自定义重构工具。有一次,我想找到一种类型的所有子类型,就像 eclipse 中的“类型层次结构” View 一样。我使用搜索引擎编写了一个遍历层次结构的递归函数。这有效,
有没有一种好方法可以访问 IType 的导入声明,而无需手动搜索源代码,可以使用 getSource() 获取 String ? 示例:如果 IType 是源文件中的 Java 类: import j
我想知道 Eclipse JDT 是否提供任何 API 函数来从 IType 实例化对象。 我们使用 Eclipse JDT 搜索引擎来检索具有特定接口(interface)的类,例如 Applica
我有一个类的 IType 对象。我想知道该类是否是抽象类。IType 或 ICompilationUnit 中是否有任何可用的方法来确定相同的(反射除外)。 最佳答案 IType type = ...
我尝试执行以下操作: hibQuery.SetParameter("MyParameter", valueObject, valueType); 唯一的问题是此方法需要第三个参数中的 NHiberna
我正在开发一个插件,该插件采用工作区中实现某些接口(interface)(IDomain)的所有枚举解析代码(使用 AST)对枚举进行一些修改并将其标记为使用注释(@IDomainInfo)处理。 例
我有一个 Eclipse 插件项目,我在其中使用 org.eclipse.jdt.core.IField 、 org.eclipse.jdt.core.IType 等。现在我正在尝试在 Intelli
有没有一种简单直接的方法可以从类名中获取 IType?我认为某处一定有一些静态方法。基本上,我想做类似的事情: IType objectType = Somewhere.getType("java.l
我正在使用 AngularJS 1.6.4,我收到有关 $sce 的错误: Error: [$sce:itype] http://errors.angularjs.org/1.6.4/$sce/ity
我目前正在编写单元测试并使用 Moq 框架模拟依赖项。为此,我创建了一个 Mock,如下所示: Mock traceProviderMock = new Mock(); traceProviderMo
我有这样的代码: using System; using System.Collections.Generic; using System.Linq; public interface IMyStri
我可以使用 getMethods() 方法访问 IType 的所有方法。是否有一种有效的方法来确定这样的 IMethod 是访问器还是修改器(getter/setter)? 检查 IMethod 的名
我想播放存储在我的帆服务器中的歌曲。路径是 http://localhost:4000/images/123.mp3 . 在前端,我使用 ng-repeat 列出来自服务器的歌曲。
我正在尝试在 angularjs 中使用它们的 unicodes 显示货币符号。我创建了一个 unicode 数组,并使用 ng-repeat 来显示每个货币符号。我还使用了严格的上下文转义,但我收到
我是一名优秀的程序员,十分优秀!