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


Java ITypeHierarchy.getAllSuperInterfaces方法代码示例

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


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

示例1: getDefaultExtensions

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
/**
 * Find all default extensions for this resource type. If the type itself does
 * not declare any extensions, it may inherit extensions from any of the
 * interfaces in its super type hierarchy.
 */
public static String[] getDefaultExtensions(IType resourceType)
    throws JavaModelException {
  String[] extensions = getDeclaredDefaultExtensions(resourceType);

  // Check the super interface hierarchy for @DefaultExtensions
  if (extensions.length == 0) {
    ITypeHierarchy superHierarchy = resourceType.newSupertypeHierarchy(null);
    IType[] superInterfaces = superHierarchy.getAllSuperInterfaces(resourceType);
    for (IType superInterface : superInterfaces) {
      extensions = getDeclaredDefaultExtensions(superInterface);
      if (extensions.length > 0) {
        break;
      }
    }
  }
  return extensions;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:23,代码来源:ResourceTypeDefaultExtensions.java

示例2: isDeclaredInInterface

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public static IMethod isDeclaredInInterface(IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor) throws JavaModelException {
	Assert.isTrue(isVirtual(method));
	IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1);
	try {
		IType[] classes= hierarchy.getAllClasses();
		subMonitor.beginTask("", classes.length); //$NON-NLS-1$
		for (int i= 0; i < classes.length; i++) {
			final IType clazz= classes[i];
			IType[] superinterfaces= null;
			if (clazz.equals(hierarchy.getType()))
				superinterfaces= hierarchy.getAllSuperInterfaces(clazz);
			else
				superinterfaces= clazz.newSupertypeHierarchy(new SubProgressMonitor(subMonitor, 1)).getAllSuperInterfaces(clazz);
			for (int j= 0; j < superinterfaces.length; j++) {
				IMethod found= Checks.findSimilarMethod(method, superinterfaces[j]);
				if (found != null && !found.equals(method))
					return found;
			}
			subMonitor.worked(1);
		}
		return null;
	} finally {
		subMonitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:MethodChecks.java

示例3: findInterfaces

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public Collection<IType> findInterfaces(IType type, IProgressMonitor progressMonitor) {
    ITypeHierarchy typeHierarchy;

    try {
        typeHierarchy = type.newSupertypeHierarchy(progressMonitor);

        IType[] interfaces = typeHierarchy.getAllSuperInterfaces(type);
        HashSet<IType> result = new HashSet<IType>(Arrays.asList(interfaces));

        return result;
    } catch (JavaModelException e) {
        JavaPlugin.log(e);
    }

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

示例4: collectChildrenWithMissingSerialVersionId

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void collectChildrenWithMissingSerialVersionId(IJavaElement[] children, IType serializable, List<IType> result) throws JavaModelException {
	for (int i = 0; i < children.length; i++) {
		IJavaElement child = children[i];
		if (child instanceof IType) {
			IType type = (IType) child;

			if (type.isClass()) {
				IField field = type.getField(NAME_FIELD);
				if (!field.exists()) {
					ITypeHierarchy hierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
					IType[] interfaces = hierarchy.getAllSuperInterfaces(type);
					for (int j = 0; j < interfaces.length; j++) {
						if (interfaces[j].equals(serializable)) {
							result.add(type);
							break;
						}
					}
				}
			}

			collectChildrenWithMissingSerialVersionId(type.getChildren(), serializable, result);
		} else if (child instanceof IMethod) {
			collectChildrenWithMissingSerialVersionId(((IMethod) child).getChildren(), serializable, result);
		} else if (child instanceof IField) {
			collectChildrenWithMissingSerialVersionId(((IField) child).getChildren(), serializable, result);
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:29,代码来源:PotentialProgrammingProblemsFix.java

示例5: checkValidInterfacesInDeclaringTypeHierarchy

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private RefactoringStatus checkValidInterfacesInDeclaringTypeHierarchy(IMethod sourceMethod,
		Optional<IProgressMonitor> monitor) throws JavaModelException {
	RefactoringStatus status = new RefactoringStatus();

	monitor.ifPresent(m -> m.beginTask("Checking valid interfaces in declaring type hierarchy ...",
			IProgressMonitor.UNKNOWN));
	try {
		ITypeHierarchy hierarchy = this.getDeclaringTypeHierarchy(sourceMethod, monitor);
		IType[] declaringTypeSuperInterfaces = hierarchy.getAllSuperInterfaces(sourceMethod.getDeclaringType());

		// the number of methods sourceMethod is implementing.
		long numberOfImplementedMethods = Arrays.stream(declaringTypeSuperInterfaces).parallel().distinct().flatMap(
				i -> Arrays.stream(Optional.ofNullable(i.findMethods(sourceMethod)).orElse(new IMethod[] {})))
				.count();

		if (numberOfImplementedMethods > 1)
			addErrorAndMark(status, PreconditionFailure.SourceMethodImplementsMultipleMethods, sourceMethod);

		// for each subclass of the declaring type.
		for (IType subclass : hierarchy.getSubclasses(sourceMethod.getDeclaringType()))
			status.merge(checkClassForMissingSourceMethodImplementation(sourceMethod, subclass, hierarchy,
					monitor.map(m -> new SubProgressMonitor(m, IProgressMonitor.UNKNOWN))));
	} finally {
		monitor.ifPresent(IProgressMonitor::done);
	}
	return status;
}
 
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:28,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java

示例6: collectChildrenWithMissingSerialVersionId

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void collectChildrenWithMissingSerialVersionId(
    IJavaElement[] children, IType serializable, List<IType> result) throws JavaModelException {
  for (int i = 0; i < children.length; i++) {
    IJavaElement child = children[i];
    if (child instanceof IType) {
      IType type = (IType) child;

      if (type.isClass()) {
        IField field = type.getField(NAME_FIELD);
        if (!field.exists()) {
          ITypeHierarchy hierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
          IType[] interfaces = hierarchy.getAllSuperInterfaces(type);
          for (int j = 0; j < interfaces.length; j++) {
            if (interfaces[j].equals(serializable)) {
              result.add(type);
              break;
            }
          }
        }
      }

      collectChildrenWithMissingSerialVersionId(type.getChildren(), serializable, result);
    } else if (child instanceof IMethod) {
      collectChildrenWithMissingSerialVersionId(
          ((IMethod) child).getChildren(), serializable, result);
    } else if (child instanceof IField) {
      collectChildrenWithMissingSerialVersionId(
          ((IField) child).getChildren(), serializable, result);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:PotentialProgrammingProblemsFix.java

示例7: isDeclaredInInterface

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
public static IMethod isDeclaredInInterface(
    IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor)
    throws JavaModelException {
  Assert.isTrue(isVirtual(method));
  IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
  try {
    IType[] classes = hierarchy.getAllClasses();
    subMonitor.beginTask("", classes.length); // $NON-NLS-1$
    for (int i = 0; i < classes.length; i++) {
      final IType clazz = classes[i];
      IType[] superinterfaces = null;
      if (clazz.equals(hierarchy.getType()))
        superinterfaces = hierarchy.getAllSuperInterfaces(clazz);
      else
        superinterfaces =
            clazz
                .newSupertypeHierarchy(new SubProgressMonitor(subMonitor, 1))
                .getAllSuperInterfaces(clazz);
      for (int j = 0; j < superinterfaces.length; j++) {
        IMethod found = Checks.findSimilarMethod(method, superinterfaces[j]);
        if (found != null && !found.equals(method)) return found;
      }
      subMonitor.worked(1);
    }
    return null;
  } finally {
    subMonitor.done();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:MethodChecks.java

示例8: collectChildrenWithMissingSerialVersionId

import org.eclipse.jdt.core.ITypeHierarchy; //导入方法依赖的package包/类
private void collectChildrenWithMissingSerialVersionId(IJavaElement[] children, IType serializable, List<IType> result) throws JavaModelException {
	for (int i= 0; i < children.length; i++) {
		IJavaElement child= children[i];
		if (child instanceof IType) {
			IType type= (IType)child;

			if (type.isClass()) {
  					IField field= type.getField(NAME_FIELD);
  					if (!field.exists()) {
  						ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor());
  						IType[] interfaces= hierarchy.getAllSuperInterfaces(type);
  						for (int j= 0; j < interfaces.length; j++) {
  							if (interfaces[j].equals(serializable)) {
  								result.add(type);
  								break;
  							}
  						}
				}
			}

			collectChildrenWithMissingSerialVersionId(type.getChildren(), serializable, result);
		} else if (child instanceof IMethod) {
			collectChildrenWithMissingSerialVersionId(((IMethod)child).getChildren(), serializable, result);
		} else if (child instanceof IField) {
			collectChildrenWithMissingSerialVersionId(((IField)child).getChildren(), serializable, result);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:PotentialProgrammingProblemsFix.java


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