@Override public boolean hasChildren(final Object element) { if (!(element instanceof IType)) return false; final IType type= (IType) element; return (fHierarchy.getAllSubtypes(type).length > 0) || fTypeToMemberArray.containsKey(type); }
@Override public boolean hasChildren(final Object element) { if (!(element instanceof IType)) return false; final IType type= (IType) element; return (fHierarchy.getAllSubtypes(type).length > 0) || fTypeToMemberArray.containsKey(type); }
public boolean hasChildren(final Object element) { if (!(element instanceof IType)) return false; final IType type= (IType) element; return (fHierarchy.getAllSubtypes(type).length > 0) || fTypeToMemberArray.containsKey(type); }
/** * 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(); }
private static Set<IType> computeShowableSubtypesOfMainType(final ITypeHierarchy hierarchy, final Map<IType, IMember[]> typeToMemberArray) { final Set<IType> result= new HashSet<>(); 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; }
/** * 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(); }
private static Set<IType> computeShowableSubtypesOfMainType(final ITypeHierarchy hierarchy, final Map<IType, IMember[]> typeToMemberArray) { final Set<IType> result= new HashSet<>(); 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; }
private static Set computeShowableSubtypesOfMainType(final ITypeHierarchy hierarchy, final Map typeToMemberArray) { final Set result= new HashSet(); 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; }
IProject project; //currently selected project //get the java project and locate the interface type JavaProject javaProject = JavaCore.create(project); IType myInterface = javaProject.findType("MyInterface","name.seller.rich"); //get the sub types from the interface's type hierarchy ITypeHierarchy hierarchy = myInterface .newTypeHierarchy(new NullProgressMonitor()); IType[] subTypes = hierarchy.getAllSubtypes(myInterface ); //do something with the sub types ...
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 result= new ArrayList(subTypes.length); for (int i= 0; i < subTypes.length; i++) { if (! subTypes[i].isBinary()) { result.add(subTypes[i]); } } return (IType[]) result.toArray(new IType[result.size()]); }
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<>(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()]); }
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<>(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()]); }
private ICompilationUnit[] getAffectedCompilationUnits(final IProgressMonitor monitor) throws JavaModelException { final IType[] allSubtypes= getDestinationTypeHierarchy(monitor).getAllSubtypes(getDestinationType()); final Set result= new HashSet(allSubtypes.length); for (int i= 0; i < allSubtypes.length; i++) { result.add(allSubtypes[i].getCompilationUnit()); } result.add(getDestinationType().getCompilationUnit()); return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]); }
private List<T> findTypeImplementations(IProgressMonitor monitor) throws JavaModelException { IType type = (IType) javaElement; List<T> results = null; try { String typeLabel = JavaElementLabelsCore.getElementLabel(type, JavaElementLabelsCore.DEFAULT_QUALIFIED); monitor.beginTask(Messages.format(JavaElementImplementationHyperlink_search_method_implementors, typeLabel), 10); IType[] allTypes = type.newTypeHierarchy(monitor).getAllSubtypes(type); results = Arrays.stream(allTypes).map(el -> mapper.convert(el, 0, 0)).filter(Objects::nonNull).collect(Collectors.toList()); if (monitor.isCanceled()) { throw new OperationCanceledException(); } } finally { monitor.done(); } return results; }
private ICompilationUnit[] getAffectedCompilationUnits(final IProgressMonitor monitor) throws JavaModelException { final IType[] allSubtypes= getDestinationTypeHierarchy(monitor).getAllSubtypes(getDestinationType()); final Set<ICompilationUnit> result= new HashSet<>(allSubtypes.length); for (int i= 0; i < allSubtypes.length; i++) { ICompilationUnit cu= allSubtypes[i].getCompilationUnit(); if (cu != null) result.add(cu); } result.add(getDestinationType().getCompilationUnit()); return result.toArray(new ICompilationUnit[result.size()]); }
private ICompilationUnit[] getAffectedCompilationUnits(final IProgressMonitor monitor) throws JavaModelException { final IType[] allSubtypes= getDestinationTypeHierarchy(monitor).getAllSubtypes(getDestinationType()); final Set<ICompilationUnit> result= new HashSet<>(allSubtypes.length); for (int i= 0; i < allSubtypes.length; i++) { ICompilationUnit cu= allSubtypes[i].getCompilationUnit(); if (cu != null) result.add(cu); } result.add(getDestinationType().getCompilationUnit()); return result.toArray(new ICompilationUnit[result.size()]); }
public static void findTestImplementorClasses(ITypeHierarchy typeHierarchy, IType testInterface, IRegion region, Set<IType> result) throws JavaModelException { IType[] subtypes= typeHierarchy.getAllSubtypes(testInterface); for (int i= 0; i < subtypes.length; i++) { IType type= subtypes[i]; int cachedFlags= typeHierarchy.getCachedFlags(type); if (!Flags.isInterface(cachedFlags) && !Flags.isAbstract(cachedFlags) // do the cheaper tests first && region.contains(type) && CoreTestSearchEngine.isAccessibleClass(type)) { result.add(type); } } }
public static void findTestImplementorClasses(ITypeHierarchy typeHierarchy, IType testInterface, IRegion region, Set result) throws JavaModelException { IType[] subtypes= typeHierarchy.getAllSubtypes(testInterface); for (int i= 0; i < subtypes.length; i++) { IType type= subtypes[i]; int cachedFlags= typeHierarchy.getCachedFlags(type); if (!Flags.isInterface(cachedFlags) && !Flags.isAbstract(cachedFlags) // do the cheaper tests first && region.contains(type) && CoreTestSearchEngine.isAccessibleClass(type)) { result.add(type); } } }
@SuppressWarnings("synthetic-access") @Override public void run(IProgressMonitor pm) throws InvocationTargetException { try { final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); final IJavaProject javaProject = JavaCore.create(project); final IType agentType = javaProject.findType("io.sarl.lang.core.Agent"); //$NON-NLS-1$ res[0] = agentType.newTypeHierarchy(pm).getAllSubtypes(agentType); } catch (JavaModelException e) { setErrorMessage(e.getLocalizedMessage()); JDIDebugUIPlugin.log(e); } } });
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }