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


Java ITypeHierarchy.getAllSubtypes方法代码示例

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


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

示例1: calculateValue

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * @see IJavaModel#calculateValue
 */
@Override
public void calculateValue(ICompilationUnit unit) {
	
	try {
		int length = 0;
		
		IType[] types = unit.getAllTypes();
		for (IType type : types) {
			ITypeHierarchy th= type.newTypeHierarchy((IJavaProject) type.getAncestor(IJavaElement.JAVA_PROJECT), null);
			
			if (th != null) subtypesList = th.getAllSubtypes(type);
			
			if (subtypesList != null) length = subtypesList.length;
			
			Double value = new BigDecimal(length, new MathContext(2, RoundingMode.UP)).doubleValue();
			setNocValue(value);
		}
		
	}catch (JavaModelException exception1) {
		logger.error(exception1);
	}catch (NullPointerException exception2){
		logger.error(exception2);
	}
}
 
开发者ID:mariazevedo88,项目名称:o3smeasures-tool,代码行数:28,代码来源:NumberOfChildrenJavaModel.java

示例2: findTypesWithSubMethods

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void findTypesWithSubMethods(IJavaElement element, List<Type> implementations)
    throws JavaModelException {
  IMethod selectedMethod = (IMethod) element;
  IType parentType = selectedMethod.getDeclaringType();
  if (parentType == null) {
    return;
  }
  ITypeHierarchy typeHierarchy = parentType.newTypeHierarchy(new NullProgressMonitor());
  IType[] subTypes = typeHierarchy.getAllSubtypes(parentType);

  MethodOverrideTester methodOverrideTester = new MethodOverrideTester(parentType, typeHierarchy);

  for (IType type : subTypes) {
    IMethod method = methodOverrideTester.findOverridingMethodInType(type, selectedMethod);
    if (method == null) {
      continue;
    }
    Type openDeclaration = convertToTypeDTO(type);
    setRange(openDeclaration, method);
    implementations.add(openDeclaration);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:JavaTypeHierarchy.java

示例3: getMatchingMembers

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private Map<IMember, Set<IMember>> getMatchingMembers(final ITypeHierarchy hierarchy, final IType type, final boolean includeAbstract) throws JavaModelException {
	final Map<IMember, Set<IMember>> result= new HashMap<IMember, Set<IMember>>();
	result.putAll(getMatchingMembersMapping(type));
	final IType[] subTypes= hierarchy.getAllSubtypes(type);
	for (int i= 0; i < subTypes.length; i++) {
		final Map<IMember, Set<IMember>> map= getMatchingMembersMapping(subTypes[i]);
		mergeMaps(result, map);
		upgradeMap(result, map);
	}
	if (includeAbstract)
		return result;

	for (int i= 0; i < fAbstractMethods.length; i++) {
		if (result.containsKey(fAbstractMethods[i]))
			result.remove(fAbstractMethods[i]);
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:PullUpRefactoringProcessor.java

示例4: findTypesWithMissingUID

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private IType[] findTypesWithMissingUID(IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException {
	try {
		monitor.beginTask("", compilationUnits.length); //$NON-NLS-1$

		IType serializable = project.findType(SERIALIZABLE_NAME);

		List<IType> types = new ArrayList<>();

		if (compilationUnits.length > 500) {
			//500 is a guess. Building the type hierarchy on serializable is very expensive
			//depending on how many subtypes exit in the project.

			HashSet<ICompilationUnit> cus = new HashSet<>();
			for (int i = 0; i < compilationUnits.length; i++) {
				cus.add(compilationUnits[i]);
			}

			monitor.subTask(Messages.format(FixMessages.Java50Fix_SerialVersion_CalculateHierarchy_description, SERIALIZABLE_NAME));
			ITypeHierarchy hierarchy1 = serializable.newTypeHierarchy(project, new SubProgressMonitor(monitor, compilationUnits.length));
			IType[] allSubtypes1 = hierarchy1.getAllSubtypes(serializable);
			addTypes(allSubtypes1, cus, types);
		} else {
			monitor.subTask(FixMessages.Java50Fix_InitializeSerialVersionId_subtask_description);
			for (int i = 0; i < compilationUnits.length; i++) {
				collectChildrenWithMissingSerialVersionId(compilationUnits[i].getChildren(), serializable, types);
				if (monitor.isCanceled()) {
					throw new OperationCanceledException();
				}
				monitor.worked(1);
			}
		}

		return types.toArray(new IType[types.size()]);
	} finally {
		monitor.done();
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:38,代码来源:PotentialProgrammingProblemsFix.java

示例5: findSubTypes

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void findSubTypes(IJavaElement element, List<Type> implementations)
    throws JavaModelException {
  IType type = (IType) element;
  ITypeHierarchy typeHierarchy = type.newTypeHierarchy(new NullProgressMonitor());
  IType[] implTypes = typeHierarchy.getAllSubtypes(type);

  for (IType implType : implTypes) {
    Type dto = convertToTypeDTO(implType);
    implementations.add(dto);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:JavaTypeHierarchy.java

示例6: getNonBinarySubtypes

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static IType[] getNonBinarySubtypes(WorkingCopyOwner owner, IType type, IProgressMonitor monitor) throws JavaModelException{
	ITypeHierarchy hierarchy= null;
	if (owner == null)
		hierarchy= type.newTypeHierarchy(monitor);
	else
		hierarchy= type.newSupertypeHierarchy(owner, monitor);
	IType[] subTypes= hierarchy.getAllSubtypes(type);
	List<IType> result= new ArrayList<IType>(subTypes.length);
	for (int i= 0; i < subTypes.length; i++) {
		if (! subTypes[i].isBinary()) {
			result.add(subTypes[i]);
		}
	}
	return result.toArray(new IType[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:ConstructorReferenceFinder.java

示例7: computeShowableSubtypesOfMainType

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static Set<IType> computeShowableSubtypesOfMainType(final ITypeHierarchy hierarchy, final Map<IType, IMember[]> typeToMemberArray) {
	final Set<IType> result= new HashSet<IType>();
	final IType[] subtypes= hierarchy.getAllSubtypes(hierarchy.getType());
	for (int i= 0; i < subtypes.length; i++) {
		final IType subtype= subtypes[i];
		if (canBeShown(subtype, typeToMemberArray, hierarchy))
			result.add(subtype);
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:PullUpMethodPage.java

示例8: findTypesWithMissingUID

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private IType[] findTypesWithMissingUID(IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor) throws CoreException {
	try {
		monitor.beginTask("", compilationUnits.length); //$NON-NLS-1$

		IType serializable= project.findType(SERIALIZABLE_NAME);

		List<IType> types= new ArrayList<IType>();

		if (compilationUnits.length > 500) {
			//500 is a guess. Building the type hierarchy on serializable is very expensive
			//depending on how many subtypes exit in the project.

			HashSet<ICompilationUnit> cus= new HashSet<ICompilationUnit>();
			for (int i= 0; i < compilationUnits.length; i++) {
				cus.add(compilationUnits[i]);
			}

			monitor.subTask(Messages.format(FixMessages.Java50Fix_SerialVersion_CalculateHierarchy_description, SERIALIZABLE_NAME));
			ITypeHierarchy hierarchy1= serializable.newTypeHierarchy(project, new SubProgressMonitor(monitor, compilationUnits.length));
			IType[] allSubtypes1= hierarchy1.getAllSubtypes(serializable);
			addTypes(allSubtypes1, cus, types);
		} else {
			monitor.subTask(FixMessages.Java50Fix_InitializeSerialVersionId_subtask_description);
                  for (int i= 0; i < compilationUnits.length; i++) {
                  	collectChildrenWithMissingSerialVersionId(compilationUnits[i].getChildren(), serializable, types);
                  	if (monitor.isCanceled())
                  		throw new OperationCanceledException();
                  	monitor.worked(1);
                  }
		}

		return types.toArray(new IType[types.size()]);
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:37,代码来源:PotentialProgrammingProblemsFix.java

示例9: getAllDeclaringTypeSubtypes

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private static IType[] getAllDeclaringTypeSubtypes(IMethod method) throws JavaModelException {
	IType declaringType = method.getDeclaringType();
	ITypeHierarchy typeHierarchy = declaringType.newTypeHierarchy(new NullProgressMonitor());
	IType[] allSubtypes = typeHierarchy.getAllSubtypes(declaringType);
	return allSubtypes;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:7,代码来源:EvaluateMigrateSkeletalImplementationToInterfaceRefactoringHandler.java

示例10: findTypesWithMissingUID

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private IType[] findTypesWithMissingUID(
    IJavaProject project, ICompilationUnit[] compilationUnits, IProgressMonitor monitor)
    throws CoreException {
  try {
    monitor.beginTask("", compilationUnits.length); // $NON-NLS-1$

    IType serializable = project.findType(SERIALIZABLE_NAME);

    List<IType> types = new ArrayList<IType>();

    if (compilationUnits.length > 500) {
      // 500 is a guess. Building the type hierarchy on serializable is very expensive
      // depending on how many subtypes exit in the project.

      HashSet<ICompilationUnit> cus = new HashSet<ICompilationUnit>();
      for (int i = 0; i < compilationUnits.length; i++) {
        cus.add(compilationUnits[i]);
      }

      monitor.subTask(
          Messages.format(
              FixMessages.Java50Fix_SerialVersion_CalculateHierarchy_description,
              SERIALIZABLE_NAME));
      ITypeHierarchy hierarchy1 =
          serializable.newTypeHierarchy(
              project, new SubProgressMonitor(monitor, compilationUnits.length));
      IType[] allSubtypes1 = hierarchy1.getAllSubtypes(serializable);
      addTypes(allSubtypes1, cus, types);
    } else {
      monitor.subTask(FixMessages.Java50Fix_InitializeSerialVersionId_subtask_description);
      for (int i = 0; i < compilationUnits.length; i++) {
        collectChildrenWithMissingSerialVersionId(
            compilationUnits[i].getChildren(), serializable, types);
        if (monitor.isCanceled()) throw new OperationCanceledException();
        monitor.worked(1);
      }
    }

    return types.toArray(new IType[types.size()]);
  } finally {
    monitor.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:44,代码来源:PotentialProgrammingProblemsFix.java

示例11: updateTargetVisibility

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private RefactoringStatus updateTargetVisibility(IProgressMonitor monitor)
    throws JavaModelException, CoreException {

  RefactoringStatus result = new RefactoringStatus();

  // Adjust the visibility of the method and of the referenced type. Note that
  // the target method may not be in the target type; and in this case, the type
  // of the target method does not need a visibility adjustment.

  // This method is called after all other changes have been
  // created. Changes induced by this method will be attached to those changes.

  result.merge(
      adjustVisibility(
          (IType) fIntermediaryFirstParameterType.getJavaElement(), fIntermediaryType, monitor));
  if (result.hasError()) return result; // binary

  ModifierKeyword neededVisibility = getNeededVisibility(fTargetMethod, fIntermediaryType);
  if (neededVisibility != null) {

    result.merge(adjustVisibility(fTargetMethod, neededVisibility, monitor));
    if (result.hasError()) return result; // binary

    // Need to adjust the overridden methods of the target method.
    ITypeHierarchy hierarchy = fTargetMethod.getDeclaringType().newTypeHierarchy(null);
    MethodOverrideTester tester =
        new MethodOverrideTester(fTargetMethod.getDeclaringType(), hierarchy);
    IType[] subtypes = hierarchy.getAllSubtypes(fTargetMethod.getDeclaringType());
    for (int i = 0; i < subtypes.length; i++) {
      IMethod method = tester.findOverridingMethodInType(subtypes[i], fTargetMethod);
      if (method != null && method.exists()) {
        result.merge(adjustVisibility(method, neededVisibility, monitor));
        if (monitor.isCanceled()) throw new OperationCanceledException();

        if (result.hasError()) return result; // binary
      }
    }
  }

  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:42,代码来源:IntroduceIndirectionRefactoring.java

示例12: updateTargetVisibility

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private RefactoringStatus updateTargetVisibility(IProgressMonitor monitor) throws JavaModelException, CoreException {

		RefactoringStatus result= new RefactoringStatus();

		// Adjust the visibility of the method and of the referenced type. Note that
		// the target method may not be in the target type; and in this case, the type
		// of the target method does not need a visibility adjustment.

		// This method is called after all other changes have been
		// created. Changes induced by this method will be attached to those changes.

		result.merge(adjustVisibility((IType) fIntermediaryFirstParameterType.getJavaElement(), fIntermediaryType, monitor));
		if (result.hasError())
			return result; // binary

		ModifierKeyword neededVisibility= getNeededVisibility(fTargetMethod, fIntermediaryType);
		if (neededVisibility != null) {

			result.merge(adjustVisibility(fTargetMethod, neededVisibility,  monitor));
			if (result.hasError())
				return result; // binary

			// Need to adjust the overridden methods of the target method.
			ITypeHierarchy hierarchy= fTargetMethod.getDeclaringType().newTypeHierarchy(null);
			MethodOverrideTester tester= new MethodOverrideTester(fTargetMethod.getDeclaringType(), hierarchy);
			IType[] subtypes= hierarchy.getAllSubtypes(fTargetMethod.getDeclaringType());
			for (int i= 0; i < subtypes.length; i++) {
				IMethod method= tester.findOverridingMethodInType(subtypes[i], fTargetMethod);
				if (method != null && method.exists()) {
					result.merge(adjustVisibility(method, neededVisibility, monitor));
					if (monitor.isCanceled())
						throw new OperationCanceledException();

					if (result.hasError())
						return result; // binary
				}
			}
		}

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

示例13: updateTargetVisibility

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private RefactoringStatus updateTargetVisibility(IProgressMonitor monitor) throws JavaModelException, CoreException {

		RefactoringStatus result= new RefactoringStatus();

		// Adjust the visibility of the method and of the referenced type. Note that
		// the target method may not be in the target type; and in this case, the type
		// of the target method does not need a visibility adjustment.

		// This method is called after all other changes have been
		// created. Changes induced by this method will be attached to those changes.

		result.merge(adjustVisibility((IType) fIntermediaryFirstParameterType.getJavaElement(), fIntermediaryClass, monitor));
		if (result.hasError())
			return result; // binary

		ModifierKeyword neededVisibility= getNeededVisibility(fTargetMethod, fIntermediaryClass);
		if (neededVisibility != null) {

			result.merge(adjustVisibility(fTargetMethod, neededVisibility,  monitor));
			if (result.hasError())
				return result; // binary

			// Need to adjust the overridden methods of the target method.
			ITypeHierarchy hierarchy= fTargetMethod.getDeclaringType().newTypeHierarchy(null);
			MethodOverrideTester tester= new MethodOverrideTester(fTargetMethod.getDeclaringType(), hierarchy);
			IType[] subtypes= hierarchy.getAllSubtypes(fTargetMethod.getDeclaringType());
			for (int i= 0; i < subtypes.length; i++) {
				IMethod method= tester.findOverridingMethodInType(subtypes[i], fTargetMethod);
				if (method != null && method.exists()) {
					result.merge(adjustVisibility(method, neededVisibility, monitor));
					if (monitor.isCanceled())
						throw new OperationCanceledException();

					if (result.hasError())
						return result; // binary
				}
			}
		}

		return result;
	}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:42,代码来源:IntroduceIndirectionRefactoring.java


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