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


Java ITypeHierarchy.getSuperclass方法代码示例

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


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

示例1: superClassImplementsDestinationInterface

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static boolean superClassImplementsDestinationInterface(IType type, IType destinationInterface,
		Optional<IProgressMonitor> monitor) throws JavaModelException {
	monitor.ifPresent(m -> m.beginTask("Checking superclass ...", IProgressMonitor.UNKNOWN));
	try {
		if (type.getSuperclassName() != null) { // there's a superclass.
			ITypeHierarchy superTypeHierarchy = MigrateSkeletalImplementationToInterfaceRefactoringProcessor
					.getSuperTypeHierarchy(type,
							monitor.map(m -> new SubProgressMonitor(m, IProgressMonitor.UNKNOWN)));
			IType superclass = superTypeHierarchy.getSuperclass(type);
			return Arrays.stream(superTypeHierarchy.getAllSuperInterfaces(superclass))
					.anyMatch(i -> i.equals(destinationInterface));
		}
	} finally {
		monitor.ifPresent(IProgressMonitor::done);
	}

	return true; // vacuously true since there's no superclass.
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:19,代码来源:SkeletalImplementatonClassRemovalUtils.java

示例2: getSkippedSuperTypes

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private Set<IType> getSkippedSuperTypes(final IProgressMonitor monitor) throws JavaModelException {
	monitor.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking, 1);
	try {
		if (fCachedSkippedSuperTypes != null && getDestinationTypeHierarchy(new SubProgressMonitor(monitor, 1)).getType().equals(getDestinationType()))
			return fCachedSkippedSuperTypes;
		final ITypeHierarchy hierarchy= getDestinationTypeHierarchy(new SubProgressMonitor(monitor, 1));
		fCachedSkippedSuperTypes= new HashSet<IType>(2);
		IType current= hierarchy.getSuperclass(getDeclaringType());
		while (current != null && !current.equals(getDestinationType())) {
			fCachedSkippedSuperTypes.add(current);
			current= hierarchy.getSuperclass(current);
		}
		return fCachedSkippedSuperTypes;
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:PullUpRefactoringProcessor.java

示例3: isSuperType

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public static boolean isSuperType(ITypeHierarchy hierarchy, IType possibleSuperType, IType type) {
	// filed bug 112635 to add this method to ITypeHierarchy
	IType superClass= hierarchy.getSuperclass(type);
	if (superClass != null && (possibleSuperType.equals(superClass) || isSuperType(hierarchy, possibleSuperType, superClass))) {
		return true;
	}
	if (Flags.isInterface(hierarchy.getCachedFlags(possibleSuperType))) {
		IType[] superInterfaces= hierarchy.getSuperInterfaces(type);
		for (int i= 0; i < superInterfaces.length; i++) {
			IType curr= superInterfaces[i];
			if (possibleSuperType.equals(curr) || isSuperType(hierarchy, possibleSuperType, curr)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:JavaModelUtil.java

示例4: parseKasper5DtoFields

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public static List<DtoField> parseKasper5DtoFields(IType type) {
	List<DtoField> fields = new ArrayList<>();
	try {
		/* Extraire le type parent */
		ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
		IType superclass = hierarchy.getSuperclass(type);
		for (IMethod method : superclass.getMethods()) {
			parseKasper5DtoField(method, fields);
		}
	} catch (JavaModelException e) {
		ErrorUtils.handle(e);
	}
	return fields;
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:15,代码来源:DtoUtils.java

示例5: parseKasper3PersistedDtoFields

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static void parseKasper3PersistedDtoFields(IType type, List<DtoField> fields) throws JavaModelException {

		/* Chercher les fields sur le type directement. */
		parseKasper3DtoFields(type.getCompilationUnit(), fields);

		if (fields.isEmpty()) {
			/* Chercher les fields sur le parent. */
			ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
			IType superclass = hierarchy.getSuperclass(type);
			parseKasper3DtoFields(superclass.getCompilationUnit(), fields);
		}
	}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:13,代码来源:DtoUtils.java

示例6: parseKasper3BeanFields

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static void parseKasper3BeanFields(IType type, List<DtoField> fields) throws JavaModelException {
	/* Extraire le type parent Abstract. */
	ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
	IType superclass = hierarchy.getSuperclass(type);

	for (IMethod method : superclass.getMethods()) {
		DtoField field = parseKasper3BeanFieldGetter(method);
		if (field != null) {
			fields.add(field);
		}
	}
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:13,代码来源:DtoUtils.java

示例7: visitInheritDoc

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * Visits the super types of the given <code>currentType</code>.
 *
 * @param currentType the starting type
 * @param typeHierarchy a super type hierarchy that contains <code>currentType</code>
 * @return the result from a call to {@link #visit(org.eclipse.jdt.core.IType)}, or <code>null
 *     </code> if none of the calls returned a result
 * @throws org.eclipse.jdt.core.JavaModelException unexpected problem
 */
public Object visitInheritDoc(IType currentType, ITypeHierarchy typeHierarchy)
    throws JavaModelException {
  ArrayList<IType> visited = new ArrayList<IType>();
  visited.add(currentType);
  Object result = visitInheritDocInterfaces(visited, currentType, typeHierarchy);
  if (result != InheritDocVisitor.CONTINUE) return result;

  IType superClass;
  if (currentType.isInterface())
    superClass = currentType.getJavaProject().findType("java.lang.Object"); // $NON-NLS-1$
  else superClass = typeHierarchy.getSuperclass(currentType);

  while (superClass != null && !visited.contains(superClass)) {
    result = visit(superClass);
    if (result == InheritDocVisitor.STOP_BRANCH) {
      return null;
    } else if (result == InheritDocVisitor.CONTINUE) {
      visited.add(superClass);
      result = visitInheritDocInterfaces(visited, superClass, typeHierarchy);
      if (result != InheritDocVisitor.CONTINUE) return result;
      else superClass = typeHierarchy.getSuperclass(superClass);
    } else {
      return result;
    }
  }

  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:JavadocContentAccess2.java

示例8: findFieldInHierarchy

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public static IField findFieldInHierarchy(ITypeHierarchy hierarchy,
    IType type, String fieldName) {

  IField field = findField(type, fieldName);

  // Check super class
  if (field == null) {
    IType superClass = hierarchy.getSuperclass(type);
    if (superClass != null) {
      field = findFieldInHierarchy(hierarchy, superClass, fieldName);
    }
  }

  return field;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:16,代码来源:JavaModelSearch.java

示例9: findMethodOrCtorInHierarchy

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static IMethod findMethodOrCtorInHierarchy(ITypeHierarchy hierarchy,
    IType type, String methodName, String[] paramTypes, boolean isConstructor) {
  IMethod method = findMethodOrCtor(type, methodName, paramTypes,
      isConstructor);
  if (method != null) {
    return method;
  }

  // Check super class
  IType superClass = hierarchy.getSuperclass(type);
  if (superClass != null) {
    method = findMethodOrCtorInHierarchy(hierarchy, superClass, methodName,
        paramTypes, isConstructor);
    if (method != null) {
      return method;
    }
  }

  if (!isConstructor) {
    // Check interfaces
    IType[] superInterfaces = hierarchy.getSuperInterfaces(type);
    for (IType superInterface : superInterfaces) {
      method = findMethodOrCtorInHierarchy(hierarchy, superInterface,
          methodName, paramTypes, false);
      if (method != null) {
        return method;
      }
    }
  }

  return method;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:33,代码来源:JavaModelSearch.java

示例10: checkAllParents

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void checkAllParents(final IType parent) {
	final ITypeHierarchy th= getTreeInput();
	final IType root= getTreeInput().getType();
	IType type= parent;
	while (!root.equals(type)) {
		fTreeViewer.setChecked(type, true);
		type= th.getSuperclass(type);
	}
	fTreeViewer.setChecked(root, true);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:PullUpMethodPage.java

示例11: checkException

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private IStatus checkException(final IType type) throws JavaModelException {
	ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor());
	IType curr= type;
	while (curr != null) {
		String name= curr.getFullyQualifiedName();
		if ("java.lang.Throwable".equals(name)) //$NON-NLS-1$
			return StatusInfo.OK_STATUS;
		curr= hierarchy.getSuperclass(curr);
	}
	return JavaUIStatus.createError(IStatus.ERROR,
			RefactoringMessages.ChangeExceptionsControl_not_exception, null);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:ChangeExceptionsControl.java

示例12: getParentType

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
@Override
protected IType getParentType(IType type) {
	ITypeHierarchy hierarchy= getHierarchy();
	if (hierarchy != null) {
		return hierarchy.getSuperclass(type);
		// dont handle interfaces
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:SubTypeHierarchyViewer.java

示例13: getDepth

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private int getDepth(ITypeHierarchy hierarchy, IType input) {
	int count= 0;
	IType superType= hierarchy.getSuperclass(input);
	while (superType != null) {
		count++;
		superType= hierarchy.getSuperclass(superType);
	}
	return count;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:TraditionalHierarchyViewer.java

示例14: getParentType

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
@Override
protected IType getParentType(IType type) {
	ITypeHierarchy hierarchy= getHierarchy();
	if (hierarchy != null) {
		return hierarchy.getSuperclass(type);
		// don't handle interfaces
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:TraditionalHierarchyViewer.java

示例15: visitInheritDoc

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * Visits the super types of the given <code>currentType</code>.
 *
 * @param currentType the starting type
 * @param typeHierarchy a super type hierarchy that contains <code>currentType</code>
 * @return the result from a call to {@link #visit(IType)}, or <code>null</code> if none of
 *         the calls returned a result
 * @throws JavaModelException unexpected problem
 */
public Object visitInheritDoc(IType currentType, ITypeHierarchy typeHierarchy) throws JavaModelException {
	ArrayList<IType> visited= new ArrayList<IType>();
	visited.add(currentType);
	Object result= visitInheritDocInterfaces(visited, currentType, typeHierarchy);
	if (result != InheritDocVisitor.CONTINUE)
		return result;

	IType superClass;
	if (currentType.isInterface())
		superClass= currentType.getJavaProject().findType("java.lang.Object"); //$NON-NLS-1$
	else
		superClass= typeHierarchy.getSuperclass(currentType);

	while (superClass != null && ! visited.contains(superClass)) {
		result= visit(superClass);
		if (result == InheritDocVisitor.STOP_BRANCH) {
			return null;
		} else if (result == InheritDocVisitor.CONTINUE) {
			visited.add(superClass);
			result= visitInheritDocInterfaces(visited, superClass, typeHierarchy);
			if (result != InheritDocVisitor.CONTINUE)
				return result;
			else
				superClass= typeHierarchy.getSuperclass(superClass);
		} else {
			return result;
		}
	}

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


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