本文整理汇总了Java中org.eclipse.jdt.core.ITypeHierarchy.getSubtypes方法的典型用法代码示例。如果您正苦于以下问题:Java ITypeHierarchy.getSubtypes方法的具体用法?Java ITypeHierarchy.getSubtypes怎么用?Java ITypeHierarchy.getSubtypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.ITypeHierarchy
的用法示例。
在下文中一共展示了ITypeHierarchy.getSubtypes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeInheritancePath
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
static IType[] computeInheritancePath(IType subType, IType superType) throws JavaModelException {
if (superType == null) {
return null;
}
// optimization: avoid building the type hierarchy for the identity case
if (superType.equals(subType)) {
return new IType[] { subType };
}
ITypeHierarchy hierarchy= subType.newSupertypeHierarchy(new NullProgressMonitor());
if (!hierarchy.contains(superType))
{
return null; // no path
}
List<IType> path= new LinkedList<>();
path.add(superType);
do {
// any sub type must be on a hierarchy chain from superType to subType
superType= hierarchy.getSubtypes(superType)[0];
path.add(superType);
} while (!superType.equals(subType)); // since the equality case is handled above, we can spare one check
return path.toArray(new IType[path.size()]);
}
示例2: addInHierarchy
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void addInHierarchy(IType type, ITypeHierarchy hierarchy) throws JavaModelException {
String qName = type.getFullyQualifiedName('.');
TypeNode node = getOrCreateType(qName);
if (node.isCompleteDown())
return;
//Recurse on children
for (IType sub : hierarchy.getSubtypes(type)) {
String subName = sub.getFullyQualifiedName('.');
TypeNode subNode = getOrCreateType(subName);
node.addSubtype(subNode);
subNode.addSupertype(node);
addInHierarchy(sub, hierarchy);
}
//we now have everything below this node in the hierarchy.
node.completedDown();
}
示例3: computeInheritancePath
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* Computes one inheritance path from <code>superType</code> to <code>subType</code> or <code>null
* </code> if <code>subType</code> does not inherit from <code>superType</code>. Note that there
* may be more than one inheritance path - this method simply returns one.
*
* <p>The returned array contains <code>superType</code> at its first index, and <code>subType
* </code> at its last index. If <code>subType</code> equals <code>superType</code> , an array of
* length 1 is returned containing that type.
*
* @param subType the sub type
* @param superType the super type
* @return an inheritance path from <code>superType</code> to <code>subType</code>, or <code>null
* </code> if <code>subType</code> does not inherit from <code>superType</code>
* @throws org.eclipse.jdt.core.JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
private IType[] computeInheritancePath(IType subType, IType superType) throws JavaModelException {
if (superType == null) return null;
// optimization: avoid building the type hierarchy for the identity case
if (superType.equals(subType)) return new IType[] {subType};
ITypeHierarchy hierarchy = subType.newSupertypeHierarchy(getProgressMonitor());
if (!hierarchy.contains(superType)) return null; // no path
List<IType> path = new LinkedList<IType>();
path.add(superType);
do {
// any sub type must be on a hierarchy chain from superType to subType
superType = hierarchy.getSubtypes(superType)[0];
path.add(superType);
} while (!superType.equals(
subType)); // since the equality case is handled above, we can spare one check
return path.toArray(new IType[path.size()]);
}
示例4: getTypesInHierarchy
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
@Override
protected final void getTypesInHierarchy(IType type, List<IType> res) {
ITypeHierarchy hierarchy= getHierarchy();
if (hierarchy != null) {
IType[] types= hierarchy.getSubtypes(type);
if (isObject(type)) {
for (int i= 0; i < types.length; i++) {
IType curr= types[i];
if (!isAnonymousFromInterface(curr)) {
res.add(curr);
}
}
} else {
for (int i= 0; i < types.length; i++) {
res.add(types[i]);
}
}
}
}
示例5: computeInheritancePath
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
* Computes one inheritance path from <code>superType</code> to <code>subType</code> or
* <code>null</code> if <code>subType</code> does not inherit from <code>superType</code>. Note
* that there may be more than one inheritance path - this method simply returns one.
* <p>
* The returned array contains <code>superType</code> at its first index, and
* <code>subType</code> at its last index. If <code>subType</code> equals <code>superType</code>
* , an array of length 1 is returned containing that type.
* </p>
*
* @param subType the sub type
* @param superType the super type
* @return an inheritance path from <code>superType</code> to <code>subType</code>, or
* <code>null</code> if <code>subType</code> does not inherit from
* <code>superType</code>
* @throws JavaModelException if this element does not exist or if an exception occurs while
* accessing its corresponding resource
*/
private IType[] computeInheritancePath(IType subType, IType superType) throws JavaModelException {
if (superType == null)
return null;
// optimization: avoid building the type hierarchy for the identity case
if (superType.equals(subType))
return new IType[] { subType };
ITypeHierarchy hierarchy= subType.newSupertypeHierarchy(getProgressMonitor());
if (!hierarchy.contains(superType))
return null; // no path
List<IType> path= new LinkedList<IType>();
path.add(superType);
do {
// any sub type must be on a hierarchy chain from superType to subType
superType= hierarchy.getSubtypes(superType)[0];
path.add(superType);
} while (!superType.equals(subType)); // since the equality case is handled above, we can spare one check
return path.toArray(new IType[path.size()]);
}
示例6: anySubtypeCanBeShown
import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static boolean anySubtypeCanBeShown(final IType type, final Map<IType, IMember[]> typeToMemberArray, final ITypeHierarchy hierarchy) {
final IType[] subTypes= hierarchy.getSubtypes(type);
for (int i= 0; i < subTypes.length; i++) {
if (canBeShown(subTypes[i], typeToMemberArray, hierarchy))
return true;
}
return false;
}