use of org.eclipse.n4js.ts.types.TClassifier in project n4js by eclipse.
the class TClassifierImpl method getSuperClassifiers.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Iterable<? extends TClassifier> getSuperClassifiers() {
final List<TClassifier> result = CollectionLiterals.<TClassifier>newArrayList();
final Object _superClassifierRefs = this.getSuperClassifierRefs();
for (final Object superClassifierRef : ((Iterable<?>) _superClassifierRefs)) {
if ((superClassifierRef != null)) {
final Type declType = ((TypeRef) superClassifierRef).getDeclaredType();
if ((declType instanceof TClassifier)) {
result.add(((TClassifier) declType));
}
}
}
return result;
}
use of org.eclipse.n4js.ts.types.TClassifier in project n4js by eclipse.
the class ConsumptionUtils method findInterfaceDefiningConsumedMember.
/**
* Returns the directly consumed (or otherwise inherited) classifier which indirectly provides the consumed member
* (or null, if interface is found). Usually the returned classifier is a TInterface.
*
* @param consumingClassifier
* the consuming classifier
* @param consumedMember
* the member consumed by the classifier
*/
public static TClassifier findInterfaceDefiningConsumedMember(TClassifier consumingClassifier, TMember consumedMember) {
if (consumedMember == null || !(consumedMember.eContainer() instanceof TInterface)) {
return null;
}
TInterface tinterface = (TInterface) consumedMember.eContainer();
List<TClassifier> path = findPathToInterface(consumingClassifier, tinterface);
if (path.isEmpty()) {
return null;
}
return path.get(0);
}
use of org.eclipse.n4js.ts.types.TClassifier in project n4js by eclipse.
the class TypeUtils method createConstructorTypeRef.
/**
* Creates new type reference for constructor. if the declared type is TFunction a FunctionTypeRef is created. If
* declared type is TClassifier than TypeTypeRef is created (i.e. <code>constructor{A}</code> in N4JS code)
*/
public static TypeRef createConstructorTypeRef(Type declaredType, TypeArgument... typeArgs) {
TypeRef typeRef = null;
if (declaredType instanceof TFunction) {
// TODO is this correct?
FunctionTypeRef ref = TypeRefsFactory.eINSTANCE.createFunctionTypeRef();
ref.setDeclaredType(declaredType);
for (TypeArgument typeArg : typeArgs) {
ref.getTypeArgs().add(TypeUtils.copyIfContained(typeArg));
}
typeRef = ref;
} else if (declaredType instanceof TClassifier) {
TClassifier tClassifier = (TClassifier) declaredType;
typeRef = createTypeTypeRef(createTypeRef(tClassifier, typeArgs), true);
} else if (declaredType instanceof TypeVariable) {
TypeVariable tTypeVar = (TypeVariable) declaredType;
typeRef = createTypeTypeRef(createTypeRef(tTypeVar), true);
}
return typeRef;
}
use of org.eclipse.n4js.ts.types.TClassifier in project n4js by eclipse.
the class MemberVisibilityChecker method isInternalCheckProtectedVisibile.
/**
* Unified internal check for visibility focusing on protected-stage only. Used in
* {@link #isProtectedVisible(Type, TModule, Type, TMember, boolean)} and
* {@link #isProtectedInternalVisible(Type, TModule, Type, TMember, boolean)}
*
* <p>
* Preconditions:
* <ol>
* <li>contextType != declaredReceiverType
* </ol>
*
* @param contextModule
* module where the access is issued.
* @param contextType
* containing type where the access is issued, eg. the container-type of the method, can be null if
* access happens on top-level
* @param member
* member to access.
* @param declaredReceiverType
* type on which the member will be accessed on. Not necessarily the definition type of the member but
* one of it's sub-types.
* @param supercall
* true if super-keyword was used.
*/
private boolean isInternalCheckProtectedVisibile(Type contextType, TModule contextModule, Type declaredReceiverType, TMember member, boolean supercall) {
// Protected means, that the context-type is a sub-type of the receiver-type
if (contextType == null) {
// not type information available, maybe just parsing the script: context is relevant here.
return false;
}
// contextType must be a super-type of declaredRecieverType:
List<TClassifier> receiverSuperTypes = AllSuperTypesCollector.collect((TClassifier) declaredReceiverType);
if (!receiverSuperTypes.contains(contextType)) {
// Problem: if super-keyword was usesed, the call is still valid.
if (!supercall) {
return false;
}
}
// and the member is part of a super-type (including default-method of implemented interfaces) of the
// receiver-type
TClassifier memberClsfContainer = EcoreUtil2.getContainerOfType(member, TClassifier.class);
if (declaredReceiverType instanceof TClassifier && receiverSuperTypes.contains(memberClsfContainer)) {
// definition of member is done in the super-type-tree of the receiver.
return true;
}
return false;
}
use of org.eclipse.n4js.ts.types.TClassifier in project n4js by eclipse.
the class VisibilityAwareCtorScope method isAccepted.
@Override
protected boolean isAccepted(IEObjectDescription description) {
EObject proxyOrInstance = description.getEObjectOrProxy();
if (proxyOrInstance != null && !proxyOrInstance.eIsProxy()) {
if (proxyOrInstance instanceof TClassifier) {
TClassifier ctorClassifier = (TClassifier) proxyOrInstance;
if (ctorClassifier.isAbstract()) {
// avoid duplicate error messages
return true;
}
// If the class is found, check if the visibility of the constructor is valid
TMethod usedCtor = containerTypesHelper.fromContext(context).findConstructor(ctorClassifier);
if (usedCtor != null && usedCtor.isConstructor()) {
return checker.isConstructorVisible(context, TypeUtils.createTypeRef(ctorClassifier), usedCtor);
}
}
}
return true;
}
Aggregations