IFile myJavaFile = <get the file> ICompilationUnit unit = JavaCore.createFromFile(myJavaFile); IType[] types = unit.getAllTypes(); for (IType type : types) { ITypeHierarchy th= type.newTypeHierarchy(null); // do something with the hierarchy }
private ITypeHierarchy getHierarchyOfDeclaringClass(IProgressMonitor monitor) throws JavaModelException { try { if (fCachedClassHierarchy != null) return fCachedClassHierarchy; fCachedClassHierarchy= getDeclaringType().newTypeHierarchy(monitor); return fCachedClassHierarchy; } finally { monitor.done(); } }
private ITypeHierarchy getHierarchyOfDeclaringClass(IProgressMonitor monitor) throws JavaModelException { try { if (fCachedClassHierarchy != null) return fCachedClassHierarchy; fCachedClassHierarchy= getDeclaringType().newTypeHierarchy(monitor); return fCachedClassHierarchy; } finally { monitor.done(); } }
private ITypeHierarchy getHierarchyOfDeclaringClass(IProgressMonitor monitor) throws JavaModelException { try { if (fCachedClassHierarchy != null) return fCachedClassHierarchy; fCachedClassHierarchy= getDeclaringType().newTypeHierarchy(monitor); return fCachedClassHierarchy; } finally { monitor.done(); } }
/** * Return the count of implementation for the given java element type. * * @param type the java element type. * @param monitor the monitor * @return the count of implementation for the given java element type. * @throws JavaModelException throws when Java error */ private static long countImplementations(IType type, IProgressMonitor monitor) throws JavaModelException { IType[] results = type.newTypeHierarchy(monitor).getAllSubtypes(type); return Stream.of(results).filter(t -> t.getAncestor(IJavaElement.COMPILATION_UNIT) != null).count(); }
/** * Return the count of implementation for the given java element type. * * @param type the java element type. * @param monitor the monitor * @return the count of implementation for the given java element type. * @throws JavaModelException throws when Java error */ private static long countImplementations(IType type, IProgressMonitor monitor) throws JavaModelException { IType[] results= type.newTypeHierarchy(monitor).getAllSubtypes(type); return Stream.of(results).filter(t -> t.getAncestor(IJavaElement.COMPILATION_UNIT) != null).count(); }
public Collection findImplementingTypes(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newTypeHierarchy(progressMonitor); IType[] implementingTypes = typeHierarchy.getAllClasses(); HashSet result = new HashSet(Arrays.asList(implementingTypes)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
private ITypeHierarchy getCachedHierarchy(IType declaring, IProgressMonitor monitor) throws JavaModelException { if (fCachedHierarchy != null && declaring.equals(fCachedHierarchy.getType())) { return fCachedHierarchy; } fCachedHierarchy= declaring.newTypeHierarchy(new SubProgressMonitor(monitor, 1)); return fCachedHierarchy; }
private ITypeHierarchy getCachedHierarchy(IType declaring, IProgressMonitor monitor) throws JavaModelException { if (fCachedHierarchy != null && declaring.equals(fCachedHierarchy.getType())) return fCachedHierarchy; fCachedHierarchy= declaring.newTypeHierarchy(new SubProgressMonitor(monitor, 1)); return fCachedHierarchy; }
private ITypeHierarchy getCachedHierarchy(IType declaring, IProgressMonitor monitor) throws JavaModelException { if (fCachedHierarchy != null && declaring.equals(fCachedHierarchy.getType())) return fCachedHierarchy; fCachedHierarchy= declaring.newTypeHierarchy(new SubProgressMonitor(monitor, 1)); return fCachedHierarchy; }
private ITypeHierarchy getCachedHierarchy(IType declaring, IProgressMonitor monitor) throws JavaModelException { if (fCachedHierarchy != null && declaring.equals(fCachedHierarchy.getType())) return fCachedHierarchy; fCachedHierarchy= declaring.newTypeHierarchy(new SubProgressMonitor(monitor, 1)); return fCachedHierarchy; }
private ITypeHierarchy getCachedTypeHierarchy(IProgressMonitor monitor) throws JavaModelException { if (fCachedTypeHierarchy == null) fCachedTypeHierarchy= fMethod.getDeclaringType().newTypeHierarchy(new SubProgressMonitor(monitor, 1)); return fCachedTypeHierarchy; }
public ITypeHierarchy getDestinationTypeHierarchy(final IProgressMonitor monitor) throws JavaModelException { try { if (fCachedDestinationTypeHierarchy != null && fCachedDestinationTypeHierarchy.getType().equals(getDestinationType())) return fCachedDestinationTypeHierarchy; fCachedDestinationTypeHierarchy= getDestinationType().newTypeHierarchy(fOwner, monitor); return fCachedDestinationTypeHierarchy; } finally { monitor.done(); } }
private ITypeHierarchy getCachedTypeHierarchy(IProgressMonitor monitor) throws JavaModelException { if (fCachedTypeHierarchy == null) fCachedTypeHierarchy= fMethod.getDeclaringType().newTypeHierarchy(new SubProgressMonitor(monitor, 1)); return fCachedTypeHierarchy; }
public ITypeHierarchy getDestinationTypeHierarchy(final IProgressMonitor monitor) throws JavaModelException { try { if (fCachedDestinationTypeHierarchy != null && fCachedDestinationTypeHierarchy.getType().equals(getDestinationType())) return fCachedDestinationTypeHierarchy; fCachedDestinationTypeHierarchy= getDestinationType().newTypeHierarchy(fOwner, monitor); return fCachedDestinationTypeHierarchy; } finally { monitor.done(); } }
public ITypeHierarchy getDestinationTypeHierarchy(final IProgressMonitor monitor) throws JavaModelException { try { if (fCachedDestinationTypeHierarchy != null && fCachedDestinationTypeHierarchy.getType().equals(getDestinationType())) return fCachedDestinationTypeHierarchy; fCachedDestinationTypeHierarchy= getDestinationType().newTypeHierarchy(fOwner, monitor); return fCachedDestinationTypeHierarchy; } finally { monitor.done(); } }
private ITypeHierarchy getCachedTypeHierarchy(IProgressMonitor monitor) throws JavaModelException { if (fCachedTypeHierarchy == null) fCachedTypeHierarchy= fMethod.getDeclaringType().newTypeHierarchy(new SubProgressMonitor(monitor, 1)); return fCachedTypeHierarchy; }
protected ITypeHierarchy createHierarchy(IType iTypeWithClassId, SubMonitor monitor) throws CoreException { if (useRegion()) { return createRegionHierarchy(monitor); } return iTypeWithClassId.newTypeHierarchy(monitor); }
private ITypeHierarchy createTypeHierarchy(IJavaElement element, IProgressMonitor pm) throws JavaModelException { if (element.getElementType() == IJavaElement.TYPE) { IType type= (IType) element; if (fIsSuperTypesOnly) { return type.newSupertypeHierarchy(pm); } else { return type.newTypeHierarchy(pm); } } else {
private ITypeHierarchy hierarchy(IProgressMonitor pm, WorkingCopyOwner owner, IType type) throws JavaModelException { ITypeHierarchy hierarchy= getCachedHierarchy(type, owner, new SubProgressMonitor(pm, 1)); if (hierarchy == null) hierarchy= type.newTypeHierarchy(owner, new SubProgressMonitor(pm, 1)); return hierarchy; }