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


Java ITypeHierarchy.getAllSupertypes方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.ITypeHierarchy.getAllSupertypes方法的典型用法代码示例。如果您正苦于以下问题:Java ITypeHierarchy.getAllSupertypes方法的具体用法?Java ITypeHierarchy.getAllSupertypes怎么用?Java ITypeHierarchy.getAllSupertypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.ITypeHierarchy的用法示例。


在下文中一共展示了ITypeHierarchy.getAllSupertypes方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findDocInHierarchy

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static Reader findDocInHierarchy(IMethod method, boolean useAttachedJavadoc) throws JavaModelException {
	/*
	 * Catch ExternalJavaProject in which case
	 * no hierarchy can be built.
	 */
	if (!method.getJavaProject().exists()) {
		return null;
	}

	IType type= method.getDeclaringType();
	ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null);

	MethodOverrideTester tester= new MethodOverrideTester(type, hierarchy);

	IType[] superTypes= hierarchy.getAllSupertypes(type);
	for (IType curr : superTypes) {
		IMethod overridden= tester.findOverriddenMethodInType(curr, method);
		if (overridden != null) {
			Reader reader = getHTMLContentReader(overridden, false, useAttachedJavadoc);
			if (reader != null) {
				return reader;
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:JavadocContentAccess.java

示例2: remember

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * Remembers the selection of a right hand side type (proposal type) for a certain left hand side
 * (expected type) in content assist.
 *
 * @param lhs the left hand side / expected type
 * @param rhs the selected right hand side
 */
public void remember(IType lhs, IType rhs) {
  Assert.isLegal(lhs != null);
  Assert.isLegal(rhs != null);

  try {
    if (!isCacheableRHS(rhs)) return;
    ITypeHierarchy hierarchy = rhs.newSupertypeHierarchy(getProgressMonitor());
    if (hierarchy.contains(lhs)) {
      // TODO remember for every member of the LHS hierarchy or not? Yes for now.
      IType[] allLHSides = hierarchy.getAllSupertypes(lhs);
      String rhsQualifiedName = rhs.getFullyQualifiedName();
      for (int i = 0; i < allLHSides.length; i++)
        rememberInternal(allLHSides[i], rhsQualifiedName);
      rememberInternal(lhs, rhsQualifiedName);
    }
  } catch (JavaModelException x) {
    JavaPlugin.log(x);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:ContentAssistHistory.java

示例3: remember

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * Remembers the selection of a right hand side type (proposal type) for a certain left hand side (expected
 * type) in content assist.
 *
 * @param lhs the left hand side / expected type
 * @param rhs the selected right hand side
 */
public void remember(IType lhs, IType rhs) {
	Assert.isLegal(lhs != null);
	Assert.isLegal(rhs != null);

	try {
		if (!isCacheableRHS(rhs))
			return;
		ITypeHierarchy hierarchy= rhs.newSupertypeHierarchy(getProgressMonitor());
		if (hierarchy.contains(lhs)) {
			// TODO remember for every member of the LHS hierarchy or not? Yes for now.
			IType[] allLHSides= hierarchy.getAllSupertypes(lhs);
			String rhsQualifiedName= rhs.getFullyQualifiedName();
			for (int i= 0; i < allLHSides.length; i++)
				rememberInternal(allLHSides[i], rhsQualifiedName);
			rememberInternal(lhs, rhsQualifiedName);
		}
	} catch (JavaModelException x) {
		JavaPlugin.log(x);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:ContentAssistHistory.java

示例4: calculateSuperTypes

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private List<Type> calculateSuperTypes(IType type) throws JavaModelException {
  List<Type> superTypes = new ArrayList<>();
  ITypeHierarchy superTypeHierarchy = SuperTypeHierarchyCache.getTypeHierarchy(type);
  if (superTypeHierarchy != null) {
    IType[] superITypes = superTypeHierarchy.getAllSupertypes(type);
    for (IType iType : superITypes) {
      superTypes.add(convertToDTOType(iType));
    }
  }
  return superTypes;
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:JavaNavigation.java

示例5: findHintsRecursive

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void findHintsRecursive(
    IJavaElement method, IJavaElement parent, List<MethodParameters> result)
    throws JavaModelException {
  findHints(method, parent, result);

  IType type = (IType) parent;
  ITypeHierarchy typeHierarchy = type.newTypeHierarchy(new NullProgressMonitor());
  IType[] superTypes = typeHierarchy.getAllSupertypes(type);

  for (IType iType : superTypes) {
    findHintsRecursive(method, iType, result);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:ParametersHints.java

示例6: isTrueSubtypeOf

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * Returns <code>true</code> if <code>subTypeSignature</code> describes a type which is a true
 * sub type of the type described by <code>superTypeSignature</code>.
 *
 * @param subTypeSignature the potential subtype's signature
 * @param superTypeSignature the potential supertype's signature
 * @return <code>true</code> if the inheritance relationship holds
 */
private boolean isTrueSubtypeOf(String subTypeSignature, String superTypeSignature) {
  // try cheap test first
  if (subTypeSignature.equals(superTypeSignature)) return true;

  if (SignatureUtil.isJavaLangObject(subTypeSignature))
    return false; // Object has no super types

  if (Signature.getTypeSignatureKind(subTypeSignature) != Signature.BASE_TYPE_SIGNATURE
      && SignatureUtil.isJavaLangObject(superTypeSignature)) return true;

  IJavaProject project = fUnit.getJavaProject();

  try {

    if ((Signature.getTypeSignatureKind(subTypeSignature)
            & (Signature.TYPE_VARIABLE_SIGNATURE | Signature.CLASS_TYPE_SIGNATURE))
        == 0) return false;
    IType subType = project.findType(SignatureUtil.stripSignatureToFQN(subTypeSignature));
    if (subType == null) return false;

    if ((Signature.getTypeSignatureKind(superTypeSignature)
            & (Signature.TYPE_VARIABLE_SIGNATURE | Signature.CLASS_TYPE_SIGNATURE))
        == 0) return false;
    IType superType = project.findType(SignatureUtil.stripSignatureToFQN(superTypeSignature));
    if (superType == null) return false;

    ITypeHierarchy hierarchy = subType.newSupertypeHierarchy(null);
    IType[] types = hierarchy.getAllSupertypes(subType);

    for (int i = 0; i < types.length; i++) if (types[i].equals(superType)) return true;
  } catch (JavaModelException e) {
    // ignore and return false
  }

  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:CompilationUnitCompletion.java

示例7: isTrueSubtypeOf

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * Returns <code>true</code> if <code>subTypeSignature</code>
 * describes a type which is a true sub type of the type described by
 * <code>superTypeSignature</code>.
 *
 * @param subTypeSignature the potential subtype's signature
 * @param superTypeSignature the potential supertype's signature
 * @return <code>true</code> if the inheritance relationship holds
 */
private boolean isTrueSubtypeOf(String subTypeSignature, String superTypeSignature) {
	// try cheap test first
	if (subTypeSignature.equals(superTypeSignature))
		return true;

	if (SignatureUtil.isJavaLangObject(subTypeSignature))
		return false; // Object has no super types

	if (Signature.getTypeSignatureKind(subTypeSignature) != Signature.BASE_TYPE_SIGNATURE && SignatureUtil.isJavaLangObject(superTypeSignature))
		return true;

	IJavaProject project= fUnit.getJavaProject();

	try {

		if ((Signature.getTypeSignatureKind(subTypeSignature) & (Signature.TYPE_VARIABLE_SIGNATURE | Signature.CLASS_TYPE_SIGNATURE)) == 0)
			return false;
		IType subType= project.findType(SignatureUtil.stripSignatureToFQN(subTypeSignature));
		if (subType == null)
			return false;

		if ((Signature.getTypeSignatureKind(superTypeSignature) & (Signature.TYPE_VARIABLE_SIGNATURE | Signature.CLASS_TYPE_SIGNATURE)) == 0)
			return false;
		IType superType= project.findType(SignatureUtil.stripSignatureToFQN(superTypeSignature));
		if (superType == null)
			return false;

		ITypeHierarchy hierarchy= subType.newSupertypeHierarchy(null);
		IType[] types= hierarchy.getAllSupertypes(subType);

		for (int i= 0; i < types.length; i++)
			if (types[i].equals(superType))
				return true;
	} catch (JavaModelException e) {
		// ignore and return false
	}

	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:49,代码来源:CompilationUnitCompletion.java

示例8: findDocInHierarchy

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static Reader findDocInHierarchy(IMethod method, boolean isHTML, boolean useAttachedJavadoc) throws JavaModelException {
	/*
	 * Catch ExternalJavaProject in which case
	 * no hierarchy can be built.
	 */
	if (!method.getJavaProject().exists())
		return null;

	IType type= method.getDeclaringType();
	ITypeHierarchy hierarchy= type.newSupertypeHierarchy(null);

	MethodOverrideTester tester= new MethodOverrideTester(type, hierarchy);

	IType[] superTypes= hierarchy.getAllSupertypes(type);
	for (int i= 0; i < superTypes.length; i++) {
		IType curr= superTypes[i];
		IMethod overridden= tester.findOverriddenMethodInType(curr, method);
		if (overridden != null) {
			Reader reader;
			if (isHTML)
				reader= getHTMLContentReader(overridden, false, useAttachedJavadoc);
			else
				reader= getContentReader(overridden, false);
			if (reader != null)
				return reader;
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:JavadocContentAccess.java

示例9: getElements

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public Object[] getElements(Object element) {
	if (element instanceof IType) {
		IType type= (IType)element;

		List<Object> res= new ArrayList<Object>();
		try {
			ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
			if (fShowInheritedMethods && hierarchy != null) {
				IType[] allSupertypes= hierarchy.getAllSupertypes(type);
				// sort in from last to first: elements with same name
				// will show up in hierarchy order
				for (int i= allSupertypes.length - 1; i >= 0; i--) {
					IType superType= allSupertypes[i];
					if (superType.exists()) {
						addAll(superType.getMethods(), res);
						addAll(superType.getInitializers(), res);
						addAll(superType.getFields(), res);
					}
				}
			}
			if (type.exists()) {
				addAll(type.getMethods(), res);
				addAll(type.getInitializers(), res);
				addAll(type.getFields(), res);
			}
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
		return res.toArray();
	}
	return NO_ELEMENTS;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:MethodsContentProvider.java

示例10: getChildren

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object[] getChildren(Object element) {
	if (fShowOnlyMainType) {
		if (element instanceof ITypeRoot) {
			element= ((ITypeRoot)element).findPrimaryType();
		}

		if (element == null)
			return NO_CHILDREN;
	}

	if (fShowInheritedMembers && element instanceof IType) {
		IType type= (IType)element;
		if (type.getDeclaringType() == null || type.equals(fInitiallySelectedType)) {
			ITypeHierarchy th= getSuperTypeHierarchy(type);
			if (th != null) {
				List<Object> children= new ArrayList<Object>();
				IType[] superClasses= th.getAllSupertypes(type);
				children.addAll(Arrays.asList(super.getChildren(type)));
				for (int i= 0, scLength= superClasses.length; i < scLength; i++)
					children.addAll(Arrays.asList(super.getChildren(superClasses[i])));
				return children.toArray();
			}
		}
	}
	return super.getChildren(element);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:31,代码来源:JavaOutlineInformationControl.java

示例11: getInputForCategories

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private IJavaElement[] getInputForCategories() {
	if (fInput == null)
		return new IJavaElement[0];

	if (fOutlineContentProvider.isShowingInheritedMembers()) {
		IJavaElement p= fInput;
		if (p instanceof ITypeRoot) {
			p= ((ITypeRoot)p).findPrimaryType();
		}
		while (p != null && !(p instanceof IType)) {
			p= p.getParent();
		}
		if (!(p instanceof IType))
			return new IJavaElement[] {fInput};

		ITypeHierarchy hierarchy= getSuperTypeHierarchy((IType)p);
		if (hierarchy == null)
			return new IJavaElement[] {fInput};

		IType[] supertypes= hierarchy.getAllSupertypes((IType)p);
		IJavaElement[] result= new IJavaElement[supertypes.length + 1];
		result[0]= fInput;
		System.arraycopy(supertypes, 0, result, 1, supertypes.length);
		return result;
	} else {
		return new IJavaElement[] {fInput};
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:JavaOutlineInformationControl.java

示例12: getFocusedElementsAndTypes

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static IJavaElement[] getFocusedElementsAndTypes(
    SearchPattern pattern, IJavaElement focusElement, ObjectVector superTypes)
    throws JavaModelException {
  if (pattern instanceof MethodPattern) {
    // For method pattern, it needs to walk along the focus type super hierarchy
    // and add jars/projects of all the encountered types.
    IType type = (IType) pattern.focus.getAncestor(IJavaElement.TYPE);
    MethodPattern methodPattern = (MethodPattern) pattern;
    String selector = new String(methodPattern.selector);
    int parameterCount = methodPattern.parameterCount;
    ITypeHierarchy superHierarchy = type.newSupertypeHierarchy(null);
    IType[] allTypes = superHierarchy.getAllSupertypes(type);
    int length = allTypes.length;
    SimpleSet focusSet = new SimpleSet(length + 1);
    if (focusElement != null) focusSet.add(focusElement);
    for (int i = 0; i < length; i++) {
      IMethod[] methods = allTypes[i].getMethods();
      int mLength = methods.length;
      for (int m = 0; m < mLength; m++) {
        if (parameterCount == methods[m].getNumberOfParameters()
            && methods[m].getElementName().equals(selector)) {
          IPackageFragmentRoot root =
              (IPackageFragmentRoot) allTypes[i].getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
          IJavaElement element = root.isArchive() ? root : root.getParent();
          focusSet.add(element);
          if (superTypes != null) superTypes.add(allTypes[i]);
          break;
        }
      }
    }
    // Rebuilt a contiguous array
    IJavaElement[] focuses = new IJavaElement[focusSet.elementSize];
    Object[] values = focusSet.values;
    int count = 0;
    for (int i = values.length; --i >= 0; ) {
      if (values[i] != null) {
        focuses[count++] = (IJavaElement) values[i];
      }
    }
    return focuses;
  }
  if (focusElement == null) return new IJavaElement[0];
  return new IJavaElement[] {focusElement};
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:IndexSelector.java


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