use of org.eclipse.jdt.core.ITypeHierarchy in project che by eclipse.
the class IntroduceIndirectionRefactoring method updateTargetVisibility.
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())
// binary
return result;
ModifierKeyword neededVisibility = getNeededVisibility(fTargetMethod, fIntermediaryType);
if (neededVisibility != null) {
result.merge(adjustVisibility(fTargetMethod, neededVisibility, monitor));
if (result.hasError())
// binary
return result;
// 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())
// binary
return result;
}
}
}
return result;
}
use of org.eclipse.jdt.core.ITypeHierarchy in project che by eclipse.
the class InlineMethodRefactoring method checkOverridden.
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException {
//$NON-NLS-1$
pm.beginTask("", 9);
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));
//$NON-NLS-1$
pm.setTaskName("");
}
use of org.eclipse.jdt.core.ITypeHierarchy in project che by eclipse.
the class SuperTypeHierarchyCache method findTypeHierarchyInCache.
private static ITypeHierarchy findTypeHierarchyInCache(IType type) {
synchronized (fgHierarchyCache) {
for (int i = fgHierarchyCache.size() - 1; i >= 0; i--) {
HierarchyCacheEntry curr = fgHierarchyCache.get(i);
ITypeHierarchy hierarchy = curr.getTypeHierarchy();
if (!hierarchy.exists()) {
removeHierarchyEntryFromCache(curr);
} else {
if (hierarchy.contains(type)) {
curr.markAsAccessed();
return hierarchy;
}
}
}
}
return null;
}
use of org.eclipse.jdt.core.ITypeHierarchy in project flux by eclipse.
the class SuperTypeHierarchyCache method getTypeHierarchy.
/**
* Returns a super type hierarchy that contains the given type.
* The returned hierarchy may actually be based on a subtype of the
* requested type. Therefore, queries such as {@link ITypeHierarchy#getAllClasses()}
* or {@link ITypeHierarchy#getRootInterfaces()} may return more types than the same
* queries on a type hierarchy for just the given type.
*
* @param type the focus type
* @param progressMonitor progress monitor
* @return a supertype hierarchy that contains <code>type</code>
* @throws JavaModelException if a problem occurs
*/
public static ITypeHierarchy getTypeHierarchy(IType type, IProgressMonitor progressMonitor) throws JavaModelException {
ITypeHierarchy hierarchy = findTypeHierarchyInCache(type);
if (hierarchy == null) {
fgCacheMisses++;
hierarchy = type.newSupertypeHierarchy(progressMonitor);
addTypeHierarchyToCache(hierarchy);
} else {
fgCacheHits++;
}
return hierarchy;
}
use of org.eclipse.jdt.core.ITypeHierarchy in project flux by eclipse.
the class SuperTypeHierarchyCache method findTypeHierarchyInCache.
private static ITypeHierarchy findTypeHierarchyInCache(IType type) {
synchronized (fgHierarchyCache) {
for (int i = fgHierarchyCache.size() - 1; i >= 0; i--) {
HierarchyCacheEntry curr = fgHierarchyCache.get(i);
ITypeHierarchy hierarchy = curr.getTypeHierarchy();
if (!hierarchy.exists()) {
removeHierarchyEntryFromCache(curr);
} else {
if (hierarchy.contains(type)) {
curr.markAsAccessed();
return hierarchy;
}
}
}
}
return null;
}
Aggregations