Java Code Examples for org.eclipse.jdt.core.ITypeHierarchy#getAllSubtypes()
The following examples show how to use
org.eclipse.jdt.core.ITypeHierarchy#getAllSubtypes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PullUpRefactoringProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example 2
Source File: ConstructorReferenceFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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()]); }
Example 3
Source File: PullUpMethodPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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; }
Example 4
Source File: PotentialProgrammingProblemsFix.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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(); } }
Example 5
Source File: IntroduceIndirectionRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
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; }