当前位置: 首页>>代码示例>>Java>>正文


Java ITypeHierarchy.getSubtypes方法代码示例

本文整理汇总了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()]);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:TypeProposalUtils.java

示例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();
}
 
开发者ID:aroog,项目名称:code,代码行数:20,代码来源:CachedTypeHierarchyEx.java

示例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()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:LazyGenericTypeProposal.java

示例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]);
			}
		}
	}

}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:SubTypeHierarchyViewer.java

示例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()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:41,代码来源:LazyGenericTypeProposal.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:PullUpMethodPage.java


注:本文中的org.eclipse.jdt.core.ITypeHierarchy.getSubtypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。