use of org.eclipse.jdt.core.ITypeHierarchy in project che by eclipse.
the class ParametersHints method findHintsRecursive.
private void findHintsRecursive(IJavaElement method, IJavaElement parent, List<MethodParameters> result) throws JavaModelException {
findHints(method, parent, result);
IType type = (IType) parent;
ITypeHierarchy typeHierarchy = type.newTypeHierarchy(new NullProgressMonitor());
IType[] superTypes = typeHierarchy.getAllSupertypes(type);
for (IType iType : superTypes) {
findHintsRecursive(method, iType, result);
}
}
use of org.eclipse.jdt.core.ITypeHierarchy in project che by eclipse.
the class ReplaceInvocationsRefactoring 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 MemberVisibilityAdjustor method getTypeHierarchy.
/**
* Returns a cached type hierarchy for the specified type.
*
* @param type the type to get the hierarchy for
* @param monitor the progress monitor to use
* @return the type hierarchy
* @throws JavaModelException if the type hierarchy could not be created
*/
private ITypeHierarchy getTypeHierarchy(final IType type, final IProgressMonitor monitor) throws JavaModelException {
ITypeHierarchy hierarchy = null;
try {
//$NON-NLS-1$
monitor.beginTask("", 1);
monitor.setTaskName(RefactoringCoreMessages.MemberVisibilityAdjustor_checking);
try {
hierarchy = fTypeHierarchies.get(type);
if (hierarchy == null) {
if (fOwner == null) {
hierarchy = type.newSupertypeHierarchy(new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
} else {
hierarchy = type.newSupertypeHierarchy(fOwner, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
}
fTypeHierarchies.put(type, hierarchy);
}
} finally {
monitor.done();
}
} finally {
monitor.done();
}
return hierarchy;
}
use of org.eclipse.jdt.core.ITypeHierarchy in project che by eclipse.
the class MemberVisibilityAdjustor method thresholdTypeToMethod.
/**
* Returns the visibility threshold from a type to a method.
*
* @param referencing the referencing type
* @param referenced the referenced method
* @param monitor the progress monitor to use
* @return the visibility keyword corresponding to the threshold, or <code>null</code> for default visibility
* @throws JavaModelException if the java elements could not be accessed
*/
private ModifierKeyword thresholdTypeToMethod(final IType referencing, final IMethod referenced, final IProgressMonitor monitor) throws JavaModelException {
final ICompilationUnit referencedUnit = referenced.getCompilationUnit();
ModifierKeyword keyword = ModifierKeyword.PUBLIC_KEYWORD;
if (referenced.getDeclaringType().equals(referencing))
keyword = ModifierKeyword.PRIVATE_KEYWORD;
else {
final ITypeHierarchy hierarchy = getTypeHierarchy(referencing, new SubProgressMonitor(monitor, 1));
final IType[] types = hierarchy.getSupertypes(referencing);
IType superType = null;
for (int index = 0; index < types.length; index++) {
superType = types[index];
if (superType.equals(referenced.getDeclaringType())) {
keyword = ModifierKeyword.PROTECTED_KEYWORD;
return keyword;
}
}
}
final ICompilationUnit typeUnit = referencing.getCompilationUnit();
if (referencedUnit != null && referencedUnit.equals(typeUnit)) {
if (referenced.getDeclaringType().getDeclaringType() != null)
keyword = null;
else
keyword = ModifierKeyword.PRIVATE_KEYWORD;
} else if (referencedUnit != null && referencedUnit.getParent().equals(typeUnit.getParent()))
keyword = null;
return keyword;
}
use of org.eclipse.jdt.core.ITypeHierarchy in project che by eclipse.
the class MemberVisibilityAdjustor method thresholdTypeToField.
/**
* Returns the visibility threshold from a type to a field.
*
* @param referencing the referencing type
* @param referenced the referenced field
* @param monitor the progress monitor to use
* @return the visibility keyword corresponding to the threshold, or <code>null</code> for default visibility
* @throws JavaModelException if the java elements could not be accessed
*/
private ModifierKeyword thresholdTypeToField(final IType referencing, final IField referenced, final IProgressMonitor monitor) throws JavaModelException {
ModifierKeyword keyword = ModifierKeyword.PUBLIC_KEYWORD;
final ICompilationUnit referencedUnit = referenced.getCompilationUnit();
if (referenced.getDeclaringType().equals(referencing))
keyword = ModifierKeyword.PRIVATE_KEYWORD;
else {
final ITypeHierarchy hierarchy = getTypeHierarchy(referencing, new SubProgressMonitor(monitor, 1));
final IType[] types = hierarchy.getSupertypes(referencing);
IType superType = null;
for (int index = 0; index < types.length; index++) {
superType = types[index];
if (superType.equals(referenced.getDeclaringType())) {
keyword = ModifierKeyword.PROTECTED_KEYWORD;
return keyword;
}
}
}
final ICompilationUnit typeUnit = referencing.getCompilationUnit();
if (referencedUnit != null && referencedUnit.equals(typeUnit))
keyword = ModifierKeyword.PRIVATE_KEYWORD;
else if (referencedUnit != null && typeUnit != null && referencedUnit.getParent().equals(typeUnit.getParent()))
keyword = null;
return keyword;
}
Aggregations