use of org.eclipse.n4js.ts.types.TMethod in project n4js by eclipse.
the class TypingStrategyFilter method apply.
@Override
public boolean apply(IEObjectDescription description) {
if (typingStrategy == TypingStrategy.DEFAULT || typingStrategy == TypingStrategy.NOMINAL) {
return true;
}
EObject proxyOrInstance = description.getEObjectOrProxy();
if (proxyOrInstance == null || proxyOrInstance.eIsProxy()) {
return true;
}
if (!(proxyOrInstance instanceof TMember)) {
return true;
}
TMember member = (TMember) proxyOrInstance;
if (member.isStatic() || member.getMemberAccessModifier() != MemberAccessModifier.PUBLIC) {
return false;
}
if (member instanceof TMethod) {
switch(typingStrategy) {
case NOMINAL:
case DEFAULT:
return true;
case STRUCTURAL_FIELDS:
case STRUCTURAL_READ_ONLY_FIELDS:
case STRUCTURAL_WRITE_ONLY_FIELDS:
case STRUCTURAL_FIELD_INITIALIZER:
return false;
case STRUCTURAL:
// including constructors
return true;
}
}
if (member instanceof TGetter) {
switch(typingStrategy) {
case NOMINAL:
case DEFAULT:
case STRUCTURAL:
case STRUCTURAL_FIELDS:
case STRUCTURAL_READ_ONLY_FIELDS:
return true;
case STRUCTURAL_WRITE_ONLY_FIELDS:
return false;
case STRUCTURAL_FIELD_INITIALIZER:
ContainerType<?> type = member.getContainingType();
NameAndAccess naa = new NameAndAccess(member.getName(), true, false);
Map<NameAndAccess, ? extends TMember> members = type.getOwnedMembersByNameAndAccess();
boolean hasSetter = members.containsKey(naa);
return hasSetter;
}
}
if (member instanceof TSetter) {
switch(typingStrategy) {
case NOMINAL:
case DEFAULT:
case STRUCTURAL:
case STRUCTURAL_FIELDS:
case STRUCTURAL_WRITE_ONLY_FIELDS:
return true;
case STRUCTURAL_READ_ONLY_FIELDS:
case STRUCTURAL_FIELD_INITIALIZER:
return false;
}
}
if (member instanceof TField) {
TField field = (TField) member;
switch(typingStrategy) {
case NOMINAL:
case DEFAULT:
case STRUCTURAL:
case STRUCTURAL_FIELDS:
return true;
case STRUCTURAL_READ_ONLY_FIELDS:
return !isWriteAccess;
case STRUCTURAL_WRITE_ONLY_FIELDS:
return isWriteAccess;
case STRUCTURAL_FIELD_INITIALIZER:
boolean isAccessable = !isWriteAccess && (!field.isFinal() || !field.isHasExpression());
return isAccessable;
}
}
return true;
}
use of org.eclipse.n4js.ts.types.TMethod in project n4js by eclipse.
the class TestDiscoveryHelper method collectSuitsForMethod.
private Collection<TestSuite> collectSuitsForMethod(final URI uri, final TModule module) {
final EObject object = module.eResource().getResourceSet().getEObject(uri, true);
if (object instanceof N4MethodDeclaration) {
final Type type = ((N4MethodDeclaration) object).getDefinedType();
if (type instanceof TMethod) {
final TMethod method = (TMethod) type;
final TestSuite testSuite = new TestSuite(getClassName(method));
testSuite.add(createTestCase(method, module));
return singletonList(testSuite);
}
}
return emptyList();
}
use of org.eclipse.n4js.ts.types.TMethod in project n4js by eclipse.
the class ContainerTypeImpl method basicSetCallableCtor.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCallableCtor(TMethod newCallableCtor, NotificationChain msgs) {
TMethod oldCallableCtor = callableCtor;
callableCtor = newCallableCtor;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypesPackage.CONTAINER_TYPE__CALLABLE_CTOR, oldCallableCtor, newCallableCtor);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.n4js.ts.types.TMethod in project n4js by eclipse.
the class TFunctionImpl method isCallableConstructor.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isCallableConstructor() {
final EObject parent = this.eContainer();
boolean _xifexpression = false;
if ((parent instanceof ContainerType<?>)) {
TMethod _callableCtor = ((ContainerType<?>) parent).getCallableCtor();
_xifexpression = (_callableCtor == this);
} else {
_xifexpression = false;
}
return _xifexpression;
}
use of org.eclipse.n4js.ts.types.TMethod in project n4js by eclipse.
the class TestDiscoveryHelper method collectSuitsForModule.
private Collection<TestSuite> collectSuitsForModule(final TModule module) {
final List<TestSuite> suites = newArrayList();
// Collect all top level non-abstract exported classes, exclude everything else.
for (final TClass clazz : from(module.getTopLevelTypes()).filter(TClass.class).filter(c -> !c.isAbstract() && c.isExported())) {
final TestSuite testSuite = new TestSuite(getClassName(clazz));
for (final TMethod method : getAllTestMethodsOfClass(clazz)) {
final TestCase testCase = createTestCase(method, module, getClassName(clazz));
testSuite.add(testCase);
}
if (!isEmpty(testSuite)) {
suites.add(testSuite);
}
}
return suites;
}
Aggregations