use of org.eclipse.jdt.core.dom.Modifier.ModifierKeyword 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