use of org.eclipse.n4js.n4JS.N4TypeDefinition in project n4js by eclipse.
the class MemberVisibilityChecker method isVisible.
/**
* Returns the MemberVisibility of the <i>member</i> of the <i>receiverType</> in the given <i>context</i>
* <i>supercall</i> indicates if the target of the context is the super type.
*/
private MemberVisibility isVisible(EObject context, TypeRef receiverType, TMember member, boolean supercall) {
// special case: union types
if (receiverType instanceof UnionTypeExpression) {
// because we use the combined accessibility for all members
for (TypeRef currUnitedTypeRef : ((UnionTypeExpression) receiverType).getTypeRefs()) if (!isVisible(context, currUnitedTypeRef, member, supercall).visibility)
return new MemberVisibility(false);
return new MemberVisibility(true);
}
// standard case:
Resource contextResource = context.eResource();
N4TypeDefinition typeDefiningContainer = EcoreUtil2.getContainerOfType(context, N4TypeDefinition.class);
Script script = EcoreUtil2.getContainerOfType(typeDefiningContainer != null ? typeDefiningContainer : context, Script.class);
Type contextType = null;
TModule contextModule = script.getModule();
if (typeDefiningContainer != null) {
contextType = typeDefiningContainer.getDefinedType();
}
Type declaredReceiverType = getActualDeclaredReceiverType(context, receiverType, contextResource.getResourceSet());
if (declaredReceiverType != null && typeVisibilityChecker.isVisible(contextResource, declaredReceiverType).visibility) {
// check for local usage of locally defined member
if (shortcutIsVisible(member, contextType, contextModule, declaredReceiverType)) {
return new MemberVisibility(true);
}
return isVisible(contextModule, contextType, declaredReceiverType, member, supercall);
}
return new MemberVisibility(false);
}
Aggregations