use of org.eclipse.n4js.typesystem.N4JSTypeSystem in project n4js by eclipse.
the class ComposedMemberFactory method allTypeRefAreEqual.
/**
* Compares the return types of the new {@link TMember}.
* <p>
* Returns true iff no new composition type is created. That is, all return {@link TypeRef}s of the siblings are
* equal.
*/
protected boolean allTypeRefAreEqual() {
N4JSTypeSystem ts = cmi.getTypeSystem();
List<TypeRef> allTypeRefs = cmi.getTypeRefsOfMemberType(METHOD, FIELD, GETTER, SETTER);
TypeRef siTypeRef = ts.createSimplifiedIntersection(allTypeRefs, cmi.getResource());
Iterator<TypeRef> typeRefIt = allTypeRefs.iterator();
while (typeRefIt.hasNext()) {
TypeRef firstNonNullTypeRef = typeRefIt.next();
if (firstNonNullTypeRef != null) {
RuleEnvironment G = cmi.getRuleEnvironmentForTypeRef(firstNonNullTypeRef);
boolean equalTypeRefs = ts.equaltypeSucceeded(G, firstNonNullTypeRef, siTypeRef);
return equalTypeRefs;
}
}
return true;
}
use of org.eclipse.n4js.typesystem.N4JSTypeSystem in project n4js by eclipse.
the class GHOLD_180_CheckInjectedSharedSingletons_PluginUITest method testInjectorsSharingSameSingleton.
/**
* Checks whether the same instance is provided by different injector instances when the class of the provided
* instance is annotated with {@code @Singleton}.
*/
@Test
public void testInjectorsSharingSameSingleton() throws Exception {
final Class<N4JSTypeSystem> testedType = N4JSTypeSystem.class;
final Singleton[] singletons = testedType.getAnnotationsByType(Singleton.class);
assertTrue(testedType.getSimpleName() + " is not annotated with " + Singleton.class.getName() + ".", !Arrays2.isEmpty(singletons));
final String injectorId = N4JSActivator.ORG_ECLIPSE_N4JS_N4JS;
final Injector parentInjector = N4JSActivator.getInstance().getInjector(injectorId);
final MockUIPlugin mockBundle = new MockUIPlugin();
try {
mockBundle.start(/* context */
null);
assertTrue("Mock bundle is not running yet.", Bundle.ACTIVE == mockBundle.getBundle().getState());
final Injector childInjector = mockBundle.getN4JSChildInjector();
final N4JSTypeSystem instanceFromParent = parentInjector.getInstance(testedType);
final N4JSTypeSystem instanceFromChild = childInjector.getInstance(testedType);
assertTrue("Expected the same instance of " + testedType.getSimpleName() + " from parent and child injectors.", instanceFromChild == instanceFromParent);
} finally {
mockBundle.stop(/* context */
null);
}
}
Aggregations